From 5092fd204eb0e0a363e243ff95d88d6e83da5889 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 16:38:50 +0100 Subject: [PATCH 1/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 307 ++- Cargo.toml | 2 +- README.md | 6 +- docs/examples/account/delete-consent-token.md | 4 +- docs/examples/account/delete-consent.md | 4 +- docs/examples/account/list-logs.md | 23 - docs/examples/apps/delete-installation.md | 4 +- docs/examples/apps/delete-key.md | 4 +- docs/examples/apps/delete-secret.md | 4 +- docs/examples/apps/delete-tokens.md | 4 +- docs/examples/apps/delete.md | 4 +- docs/examples/backups/delete-archive.md | 4 +- docs/examples/backups/delete-policy.md | 4 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 2 +- docs/examples/documentsdb/create-documents.md | 2 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 2 +- .../embeddings/create-text-embeddings.md | 2 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/delete-backup-policy.md | 4 +- docs/examples/mongo/delete-backup.md | 4 +- docs/examples/mongo/delete.md | 4 +- docs/examples/mysql/delete-backup-policy.md | 4 +- docs/examples/mysql/delete-backup.md | 4 +- docs/examples/mysql/delete.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/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 25 - .../organization/delete-installation.md | 4 +- docs/examples/organization/delete-key.md | 20 - docs/examples/organization/get-key.md | 22 - docs/examples/organization/list-keys.md | 23 - docs/examples/organization/update-key.md | 25 - .../postgresql/delete-backup-policy.md | 4 +- docs/examples/postgresql/delete-backup.md | 4 +- docs/examples/postgresql/delete.md | 4 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- docs/examples/sites/delete-log.md | 4 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 2 +- docs/examples/tablesdb/delete-migration.md | 4 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 2 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/delete-installation.md | 4 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/list-logs.md | 24 - docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 2 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 2 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 2 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- src/client.rs | 216 +- src/enums/billing_plan_group.rs | 5 +- src/enums/execution_method.rs | 2 +- src/enums/image_gravity.rs | 6 +- src/enums/mod.rs | 2 - src/enums/organization_key_scopes.rs | 72 - src/lib.rs | 4 +- src/models/activity_event.rs | 145 ++ src/models/activity_event_list.rs | 10 + src/models/additional_resource.rs | 30 + src/models/algo_argon2.rs | 20 + src/models/algo_bcrypt.rs | 5 + src/models/algo_md5.rs | 5 + src/models/algo_phpass.rs | 5 + src/models/algo_scrypt.rs | 25 + src/models/algo_scrypt_modified.rs | 20 + src/models/algo_sha.rs | 5 + src/models/app.rs | 130 ++ src/models/app_installation.rs | 45 + src/models/app_installation_list.rs | 10 + src/models/app_key.rs | 40 + src/models/app_key_list.rs | 10 + src/models/app_scope.rs | 25 + src/models/app_scope_list.rs | 10 + src/models/app_secret.rs | 40 + src/models/app_secret_list.rs | 10 + src/models/app_secret_plaintext.rs | 40 + src/models/apps_list.rs | 10 + src/models/attribute_bigint.rs | 30 + src/models/attribute_boolean.rs | 30 + src/models/attribute_datetime.rs | 30 + src/models/attribute_email.rs | 35 + src/models/attribute_enum.rs | 40 + src/models/attribute_float.rs | 30 + src/models/attribute_integer.rs | 30 + src/models/attribute_ip.rs | 35 + src/models/attribute_line.rs | 30 + src/models/attribute_list.rs | 10 + src/models/attribute_longtext.rs | 30 + src/models/attribute_mediumtext.rs | 30 + src/models/attribute_object.rs | 30 + src/models/attribute_point.rs | 30 + src/models/attribute_polygon.rs | 30 + src/models/attribute_relationship.rs | 55 + src/models/attribute_string.rs | 35 + src/models/attribute_text.rs | 30 + src/models/attribute_url.rs | 35 + src/models/attribute_varchar.rs | 35 + src/models/attribute_vector.rs | 35 + src/models/backup_archive.rs | 72 +- src/models/backup_archive_list.rs | 10 + src/models/backup_policy.rs | 50 + src/models/backup_policy_list.rs | 10 + src/models/backup_restoration.rs | 72 +- src/models/backup_restoration_list.rs | 10 + src/models/billing_plan.rs | 335 ++- src/models/billing_plan_addon_details.rs | 35 + src/models/billing_plan_supported_addons.rs | 15 + src/models/block.rs | 80 +- src/models/bucket.rs | 70 + src/models/bucket_list.rs | 10 + src/models/collection.rs | 60 + src/models/collection_list.rs | 10 + src/models/column_bigint.rs | 30 + src/models/column_boolean.rs | 30 + src/models/column_datetime.rs | 30 + src/models/column_email.rs | 35 + src/models/column_enum.rs | 40 + src/models/column_float.rs | 30 + src/models/column_index.rs | 45 + src/models/column_index_list.rs | 10 + src/models/column_integer.rs | 30 + src/models/column_ip.rs | 35 + src/models/column_line.rs | 30 + src/models/column_list.rs | 10 + src/models/column_longtext.rs | 30 + src/models/column_mediumtext.rs | 30 + src/models/column_point.rs | 30 + src/models/column_polygon.rs | 30 + src/models/column_relationship.rs | 55 + src/models/column_string.rs | 35 + src/models/column_text.rs | 30 + src/models/column_url.rs | 35 + src/models/column_varchar.rs | 35 + src/models/continent.rs | 10 + src/models/continent_list.rs | 10 + src/models/country.rs | 10 + src/models/country_list.rs | 10 + src/models/currency.rs | 35 + src/models/currency_list.rs | 10 + src/models/database.rs | 35 +- src/models/database_list.rs | 10 + src/models/database_migration.rs | 85 + src/models/database_migration_list.rs | 10 + src/models/database_status.rs | 74 +- src/models/database_status_connections.rs | 10 + src/models/database_status_replica.rs | 15 + src/models/database_status_volume.rs | 20 + src/models/dedicated_database.rs | 316 ++- src/models/dedicated_database_backup.rs | 60 + src/models/dedicated_database_backup_list.rs | 10 + .../dedicated_database_backup_storage.rs | 25 + src/models/dedicated_database_branch.rs | 69 +- src/models/dedicated_database_branch_list.rs | 10 + src/models/dedicated_database_execution.rs | 30 + .../dedicated_database_execution_column.rs | 10 + src/models/dedicated_database_extensions.rs | 15 + src/models/dedicated_database_list.rs | 10 + src/models/dedicated_database_member.rs | 15 + src/models/dedicated_database_operation.rs | 40 + .../dedicated_database_operation_list.rs | 10 + src/models/dedicated_database_pitr_windows.rs | 10 + src/models/dedicated_database_pooler.rs | 50 + src/models/dedicated_database_replicas.rs | 30 + src/models/dedicated_database_restoration.rs | 105 +- .../dedicated_database_restoration_list.rs | 10 + .../dedicated_database_specification.rs | 121 +- .../dedicated_database_specification_list.rs | 19 +- ...edicated_database_specification_pricing.rs | 68 - src/models/deployment.rs | 130 ++ src/models/deployment_list.rs | 10 + src/models/dev_key.rs | 104 - src/models/document.rs | 35 + src/models/document_list.rs | 10 + src/models/email_template.rs | 40 + src/models/email_template_list.rs | 10 + src/models/embedding.rs | 20 + src/models/embedding_list.rs | 10 + src/models/ephemeral_key.rs | 45 + src/models/execution.rs | 82 +- src/models/execution_list.rs | 10 + src/models/file.rs | 80 + src/models/file_list.rs | 10 + src/models/framework.rs | 25 + src/models/framework_adapter.rs | 20 + src/models/framework_list.rs | 10 + src/models/function.rs | 160 ++ src/models/function_list.rs | 10 + src/models/headers.rs | 10 + src/models/identity.rs | 69 +- src/models/identity_list.rs | 10 + src/models/index.rs | 40 + src/models/index_list.rs | 10 + src/models/insight.rs | 70 + src/models/insight_cta.rs | 20 + src/models/insight_list.rs | 10 + src/models/jwt.rs | 5 + src/models/key.rs | 45 + src/models/key_list.rs | 10 + src/models/language.rs | 15 + src/models/language_list.rs | 10 + src/models/locale.rs | 35 + src/models/locale_code.rs | 10 + src/models/locale_code_list.rs | 10 + src/models/log.rs | 235 -- src/models/log_list.rs | 49 - src/models/membership.rs | 75 + src/models/membership_list.rs | 10 + src/models/message.rs | 50 + src/models/message_list.rs | 10 + src/models/mfa_challenge.rs | 20 + src/models/mfa_challenge_secret.rs | 25 + src/models/mfa_factors.rs | 25 + src/models/mfa_recovery_codes.rs | 5 + src/models/mfa_type.rs | 10 + src/models/mock_number.rs | 20 + src/models/mock_number_list.rs | 10 + src/models/mod.rs | 36 +- src/models/o_auth2_amazon.rs | 20 + src/models/o_auth2_apple.rs | 68 +- src/models/o_auth2_appwrite.rs | 20 + src/models/o_auth2_auth0.rs | 44 +- src/models/o_auth2_authentik.rs | 25 + src/models/o_auth2_autodesk.rs | 20 + src/models/o_auth2_bitbucket.rs | 20 + src/models/o_auth2_bitly.rs | 20 + src/models/o_auth2_box.rs | 20 + src/models/o_auth2_cloudflare.rs | 20 + src/models/o_auth2_dailymotion.rs | 20 + src/models/o_auth2_discord.rs | 39 +- src/models/o_auth2_disqus.rs | 20 + src/models/o_auth2_dropbox.rs | 20 + src/models/o_auth2_etsy.rs | 20 + src/models/o_auth2_facebook.rs | 20 + src/models/o_auth2_figma.rs | 20 + src/models/o_auth2_fusion_auth.rs | 25 + src/models/o_auth2_github.rs | 39 +- src/models/o_auth2_gitlab.rs | 25 + src/models/o_auth2_google.rs | 63 +- src/models/o_auth2_hugging_face.rs | 20 + src/models/o_auth2_keycloak.rs | 30 + src/models/o_auth2_kick.rs | 20 + src/models/o_auth2_linkedin.rs | 20 + src/models/o_auth2_microsoft.rs | 44 +- src/models/o_auth2_notion.rs | 20 + src/models/o_auth2_oidc.rs | 65 +- src/models/o_auth2_okta.rs | 49 +- src/models/o_auth2_paypal.rs | 20 + src/models/o_auth2_podio.rs | 20 + src/models/o_auth2_provider_list.rs | 10 + src/models/o_auth2_resend.rs | 20 + src/models/o_auth2_salesforce.rs | 39 +- src/models/o_auth2_slack.rs | 20 + src/models/o_auth2_spotify.rs | 20 + src/models/o_auth2_stripe.rs | 20 + src/models/o_auth2_tradeshift.rs | 20 + src/models/o_auth2_twitch.rs | 20 + src/models/o_auth2_word_press.rs | 20 + src/models/o_auth2_x.rs | 20 + src/models/o_auth2_yahoo.rs | 20 + src/models/o_auth2_yandex.rs | 20 + src/models/o_auth2_zoho.rs | 39 +- src/models/o_auth2_zoom.rs | 20 + src/models/oauth2_approve.rs | 5 + src/models/oauth2_authorize.rs | 10 + src/models/oauth2_consent.rs | 50 + src/models/oauth2_consent_list.rs | 10 + src/models/oauth2_consent_token.rs | 55 + src/models/oauth2_consent_token_list.rs | 10 + src/models/oauth2_device_authorization.rs | 30 + src/models/oauth2_grant.rs | 60 + src/models/oauth2_organization.rs | 5 + src/models/oauth2_organization_list.rs | 10 + src/models/oauth2_par.rs | 10 + src/models/oauth2_project.rs | 15 + src/models/oauth2_project_list.rs | 10 + src/models/oauth2_reject.rs | 5 + src/models/oauth2_token.rs | 25 + src/models/organization.rs | 166 +- src/models/passkey.rs | 25 + src/models/passkey_challenge.rs | 25 + src/models/passkey_list.rs | 10 + src/models/phone.rs | 15 + src/models/phone_list.rs | 10 + src/models/platform_android.rs | 44 +- src/models/platform_apple.rs | 25 + src/models/platform_linux.rs | 25 + src/models/platform_list.rs | 10 + src/models/platform_web.rs | 25 + src/models/platform_windows.rs | 25 + src/models/policy_deny_aliased_email.rs | 10 + src/models/policy_deny_corporate_email.rs | 10 + src/models/policy_deny_disposable_email.rs | 10 + src/models/policy_deny_free_email.rs | 10 + src/models/policy_list.rs | 10 + src/models/policy_membership_privacy.rs | 35 + src/models/policy_mfa_factors.rs | 25 + src/models/policy_passkey.rs | 15 + src/models/policy_password_dictionary.rs | 10 + src/models/policy_password_history.rs | 10 + src/models/policy_password_personal_data.rs | 10 + src/models/policy_password_strength.rs | 30 + src/models/policy_session_alert.rs | 10 + src/models/policy_session_duration.rs | 10 + src/models/policy_session_invalidation.rs | 10 + src/models/policy_session_limit.rs | 10 + src/models/policy_user_limit.rs | 10 + src/models/postgres_extension.rs | 20 + src/models/presence.rs | 30 + src/models/presence_list.rs | 10 + src/models/program.rs | 45 + src/models/project.rs | 139 +- src/models/project_auth_method.rs | 5 + src/models/project_list.rs | 10 + src/models/project_protocol.rs | 5 + src/models/project_service.rs | 5 + src/models/provider.rs | 40 + src/models/provider_list.rs | 10 + src/models/proxy_invalidation.rs | 20 + src/models/proxy_rule.rs | 68 +- src/models/proxy_rule_list.rs | 10 + src/models/report.rs | 55 + src/models/report_list.rs | 10 + src/models/resource_token.rs | 35 + src/models/resource_token_list.rs | 10 + src/models/row.rs | 35 + src/models/row_list.rs | 10 + src/models/runtime.rs | 40 + src/models/runtime_list.rs | 10 + src/models/session.rs | 145 ++ src/models/session_list.rs | 10 + src/models/site.rs | 165 ++ src/models/site_list.rs | 10 + src/models/specification.rs | 20 + src/models/specification_list.rs | 10 + src/models/subscriber.rs | 40 + src/models/subscriber_list.rs | 10 + src/models/table.rs | 60 + src/models/table_list.rs | 10 + src/models/target.rs | 40 + src/models/target_list.rs | 10 + src/models/team.rs | 25 + src/models/team_list.rs | 10 + src/models/token.rs | 30 + src/models/token_secret.rs | 30 + src/models/topic.rs | 44 +- src/models/topic_list.rs | 10 + src/models/transaction.rs | 30 + src/models/transaction_list.rs | 10 + src/models/usage_billing_plan.rs | 118 +- src/models/user.rs | 75 + src/models/user_list.rs | 10 + src/models/variable.rs | 40 + src/models/variable_list.rs | 10 + src/models/vectorsdb_collection.rs | 65 + src/models/vectorsdb_collection_list.rs | 10 + src/models/webhook.rs | 67 +- src/models/webhook_list.rs | 10 + src/services/account.rs | 177 +- src/services/activities.rs | 12 +- src/services/advisor.rs | 61 +- src/services/apps.rs | 328 ++- src/services/avatars.rs | 27 +- src/services/backups.rs | 82 +- src/services/databases.rs | 1870 +++++++++++++-- src/services/documents_db.rs | 741 +++++- src/services/functions.rs | 386 ++- src/services/messaging.rs | 352 ++- src/services/mongo.rs | 433 +++- src/services/mysql.rs | 469 +++- src/services/oauth2.rs | 47 +- src/services/organization.rs | 230 +- src/services/postgresql.rs | 517 +++- src/services/presences.rs | 49 +- src/services/project.rs | 212 +- src/services/proxy.rs | 39 +- src/services/sites.rs | 381 ++- src/services/storage.rs | 209 +- src/services/tables_db.rs | 2074 +++++++++++++++-- src/services/teams.rs | 286 ++- src/services/tokens.rs | 85 +- src/services/users.rs | 500 +++- src/services/vectors_db.rs | 669 +++++- src/services/webhooks.rs | 49 +- tests/tests.rs | 66 +- 410 files changed, 18674 insertions(+), 2523 deletions(-) delete mode 100644 docs/examples/account/list-logs.md delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/delete-key.md delete mode 100644 docs/examples/organization/get-key.md delete mode 100644 docs/examples/organization/list-keys.md delete mode 100644 docs/examples/organization/update-key.md delete mode 100644 docs/examples/users/list-logs.md delete mode 100644 src/enums/organization_key_scopes.rs delete mode 100644 src/models/dedicated_database_specification_pricing.rs delete mode 100644 src/models/dev_key.rs delete mode 100644 src/models/log.rs delete mode 100644 src/models/log_list.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index ed2831c..926c3be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.16.0] - TBD +## [0.20.0] - TBD ### Added - Initial release of Appwrite Rust SDK -- Full support for Appwrite API 2.0.0 +- Full support for Appwrite API 2.5.0 - Async/await support with tokio runtime - Built-in error handling with custom error types - File upload support with automatic chunking @@ -22,25 +22,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Automatic JSON serialization/deserialization ### Features -- Account service with 59 methods +- Account service with 71 methods - Activities service with 2 methods - Apps service with 22 methods -- Avatars service with 9 methods +- Avatars service with 11 methods - Backups service with 12 methods - Databases service with 71 methods - DocumentsDB service with 37 methods +- Domains service with 47 methods - Embeddings service with 1 methods - Functions service with 26 methods - Graphql service with 2 methods - Locale service with 8 methods -- Messaging service with 54 methods +- Messaging service with 56 methods - Mongo service with 31 methods - Mysql service with 34 methods -- Oauth2 service with 12 methods +- Oauth2 service with 13 methods - Organization service with 23 methods - Postgresql service with 37 methods - Presences service with 5 methods -- Project service with 105 methods +- Project service with 116 methods - Proxy service with 9 methods - Advisor service with 5 methods - Sites service with 25 methods @@ -48,8 +49,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - TablesDB service with 81 methods - Teams service with 18 methods - Tokens service with 5 methods -- Users service with 50 methods +- Users service with 53 methods - VectorsDB service with 36 methods +- Waf service with 13 methods - Webhooks service with 6 methods ### Services @@ -68,7 +70,6 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `list_identities()` - Get the list of identities for the currently logged in user. - `delete_identity()` - Delete an identity by its unique ID. -- `list_logs()` - 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. - `update_mfa()` - Enable or disable MFA on an account. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. @@ -89,6 +90,12 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_name()` - Update currently logged in user account name. +- `list_passkeys()` - Get the list of verified passkeys registered by the currently logged in user. +- `create_passkey()` - 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. +- `get_passkey()` - Get a verified passkey of the currently logged in user by its unique ID. +- `update_passkey()` - Rename a passkey of the currently logged in user. +- `delete_passkey()` - 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. +- `update_passkey_verification()` - 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. - `update_password()` - Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. - `update_phone()` - Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. - `get_prefs()` - Get the preferences as a key-value object for the currently logged in user. @@ -97,12 +104,30 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_recovery()` - 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. +- `create_recovery_otp()` - 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. + +- `update_recovery_otp()` - 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. + - `list_sessions()` - Get the list of active sessions across different devices for the currently logged in user. -- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. +- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. - `create_anonymous_session()` - Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). -- `create_email_password_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. +- `create_email_password_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 limits](https://appwrite.io/docs/authentication-security#limits). +- `create_id_token_session()` - 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). + - `update_magic_url_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `update_phone_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `create_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -122,7 +147,11 @@ A user is limited to 10 active sessions at a time by default. [Learn more about If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create 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). +- `create_passkey_token()` - 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. +- `update_passkey_token()` - 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. - `create_phone_token()` - 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 /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. 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). @@ -136,6 +165,12 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ - `update_email_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. - `update_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. +- `create_email_verification_otp()` - 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. + +- `update_email_verification_otp()` - 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. + - `create_phone_verification()` - Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. - `update_phone_verification()` - Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -197,9 +232,11 @@ You can use the color and background params to change the avatar colors. By defa When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. -- `get_photo()` - 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. +- `get_photo()` - Returns the best available profile photo for a user. The endpoint tries 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, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. +- `update_photo()` - 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. +- `delete_photo()` - 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. - `get_qr()` - 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. - `get_screenshot()` - Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -332,7 +369,7 @@ The Databases service allows you to create structured collections of documents, - `increment_document_attribute()` - Increment a specific attribute of a document by a given value. - `list_indexes()` - List indexes in the collection. - `create_index()` - Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. - `get_index()` - Get an index by its unique ID. - `delete_index()` - Delete an index. @@ -341,7 +378,7 @@ Attributes can be `key`, `fulltext`, and `unique`. - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -379,6 +416,127 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Domains + +- `list()` - List all domains registered for this project. This endpoint supports pagination. +- `create()` - 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. +- `get_price()` - Get the registration price for a domain name. +- `list_prices()` - 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. +- `get()` - Get a domain by its unique ID. +- `delete()` - 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. +- `update_nameservers()` - Update the registrar nameservers for the given domain. When nameservers are not provided, +the domain will be updated to use Appwrite nameservers. +- `verify_nameservers()` - 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. +- `get_preset_google_workspace()` - List Google Workspace DNS records. +- `create_preset_google_workspace()` - Add Google Workspace DNS records to the domain. This will create the required MX records +for Google Workspace email hosting. +- `get_preset_i_cloud()` - List iCloud DNS records. +- `create_preset_i_cloud()` - Add iCloud DNS records to the domain. This will create the required MX and SPF records +for using iCloud email services with your domain. +- `get_preset_mailgun()` - List Mailgun DNS records. +- `create_preset_mailgun()` - Add Mailgun DNS records to the domain. This endpoint will create the required DNS records +for Mailgun in the specified domain. +- `get_preset_outlook()` - List Outlook DNS records. +- `create_preset_outlook()` - Add Outlook DNS records to the domain. This will create the required MX records +for setting up Outlook email hosting for your domain. +- `get_preset_proton_mail()` - List ProtonMail DNS records. +- `create_preset_proton_mail()` - Add ProtonMail DNS records to the domain. This will create the required MX records +for using ProtonMail with your custom domain. +- `get_preset_zoho()` - List Zoho DNS records. +- `create_preset_zoho()` - Add Zoho Mail DNS records to the domain. This will create the required MX records +for setting up Zoho Mail on your domain. +- `list_records()` - List DNS records for a given domain. You can use this endpoint to list all the DNS records +associated with your domain. +- `create_record_a()` - 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. +- `update_record_a()` - 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. +- `create_record_aaaa()` - 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. +- `update_record_aaaa()` - 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. +- `create_record_alias()` - 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. +- `update_record_alias()` - 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. +- `create_record_caa()` - 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. +- `update_record_caa()` - 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. +- `create_record_cname()` - 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'. +- `update_record_cname()` - Update an existing CNAME record for the given domain. +- `create_record_https()` - 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. +- `update_record_https()` - 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. +- `create_record_mx()` - 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. +- `update_record_mx()` - Update an existing MX record for the given domain. +- `create_record_ns()` - 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. +- `update_record_ns()` - 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. +- `create_record_srv()` - 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. +- `update_record_srv()` - 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 +- `create_record_txt()` - 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. +- `update_record_txt()` - 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. +- `get_record()` - 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. +- `delete_record()` - Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record +from a specific domain. +- `update_team()` - 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. +- `get_transfer_status()` - Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. +- `get_zone()` - 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. +- `update_zone()` - 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. + #### Embeddings - `create_text_embeddings()` - Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. @@ -463,6 +621,8 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `create_apns_provider()` - Create a new Apple Push Notification service provider. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. +- `create_appwrite_provider()` - Create a new Appwrite push provider. +- `update_appwrite_provider()` - Update an Appwrite push provider by its unique ID. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `update_fcm_provider()` - Update a Firebase Cloud Messaging provider by its unique ID. @@ -509,7 +669,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -543,7 +703,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -584,6 +744,7 @@ The OAuth2 service allows you to authorize apps and issue standards-based OAuth2 - `create_device_authorization()` - Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. - `create_grant()` - Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. - `get_grant()` - Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. +- `introspect()` - 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. - `list_organizations()` - 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. - `create_par()` - Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. - `list_projects()` - List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. @@ -601,11 +762,6 @@ The Organization service allows you to manage organization-level projects. - `get_installation()` - Get an app installation on the organization by its unique ID. Any organization member can read installations. - `update_installation()` - Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. - `delete_installation()` - Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked. -- `list_keys()` - Get a list of all API keys from the current organization. -- `create_key()` - Create a new organization API key. -- `get_key()` - Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. -- `update_key()` - Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. -- `delete_key()` - Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - `list_memberships()` - Get a list of all memberships from the current organization. - `create_membership()` - 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. - `get_membership()` - Get a membership from the current organization by its unique ID. @@ -616,12 +772,19 @@ The Organization service allows you to manage organization-level projects. - `get_project()` - Get a project. - `update_project()` - Update a project by its unique ID. - `delete_project()` - Delete a project by its unique ID. +- `list_project_keys()` - Get a list of all API keys of a project in your organization. +- `create_ephemeral_project_key()` - Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + +You can also create a standard API key if you need a longer-lived key instead. +- `get_project_key()` - Get a project key by its unique ID. +- `update_project_key()` - Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. +- `delete_project_key()` - Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. #### Postgresql - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -675,6 +838,11 @@ The Project service allows you to manage all the projects in your Appwrite serve - `get()` - Get a project. - `delete()` - Delete a project. - `update_auth_method()` - Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. +- `list_environments()` - Get a list of all environments of the project. You can use the query params to filter your results. +- `create_environment()` - Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. +- `get_environment()` - Get an environment of the project by its unique ID. +- `update_environment()` - Update the name of an environment of the project. +- `delete_environment()` - Delete an environment of the project, with all of its resources and users. - `list_keys()` - Get a list of all API keys from the current project. - `create_ephemeral_key()` - Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. @@ -712,6 +880,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_gitlab()` - Update the project OAuth2 Gitlab configuration. - `update_o_auth2_google()` - Update the project OAuth2 Google configuration. - `update_o_auth2_hugging_face()` - Update the project OAuth2 Hugging Face configuration. +- `update_o_auth2_kakao()` - Update the project OAuth2 Kakao configuration. - `update_o_auth2_keycloak()` - Update the project OAuth2 Keycloak configuration. - `update_o_auth2_kick()` - Update the project OAuth2 Kick configuration. - `update_o_auth2_linkedin()` - Update the project OAuth2 Linkedin configuration. @@ -727,9 +896,11 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_slack()` - Update the project OAuth2 Slack configuration. - `update_o_auth2_spotify()` - Update the project OAuth2 Spotify configuration. - `update_o_auth2_stripe()` - Update the project OAuth2 Stripe configuration. +- `update_o_auth2_tik_tok()` - Update the project OAuth2 TikTok configuration. - `update_o_auth2_tradeshift()` - Update the project OAuth2 Tradeshift configuration. - `update_o_auth2_tradeshift_sandbox()` - Update the project OAuth2 Tradeshift Sandbox configuration. - `update_o_auth2_twitch()` - Update the project OAuth2 Twitch configuration. +- `update_o_auth2_webflow()` - Update the project OAuth2 Webflow configuration. - `update_o_auth2_word_press()` - Update the project OAuth2 WordPress configuration. - `update_o_auth2_x()` - Update the project OAuth2 X configuration. - `update_o_auth2_yahoo()` - Update the project OAuth2 Yahoo configuration. @@ -739,7 +910,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `get_o_auth2_provider()` - Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. - `list_platforms()` - Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. - `create_android_platform()` - Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. -- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. +- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. - `create_apple_platform()` - Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. - `update_apple_platform()` - Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. - `create_linux_platform()` - Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. @@ -757,11 +928,14 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_deny_free_email_policy()` - Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. - `update_membership_privacy_policy()` - Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. - `update_mfa_factors_policy()` - Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. +- `update_passkey_policy()` - 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. - `update_password_dictionary_policy()` - 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. - `update_password_history_policy()` - Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. - `update_password_personal_data_policy()` - Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. +- `update_password_pwned_policy()` - 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. +- `update_password_rotation_policy()` - 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. - `update_password_strength_policy()` - Update the password strength requirements for users in the project. - `update_session_alert_policy()` - Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. - `update_session_duration_policy()` - Update maximum duration how long sessions created within a project should stay active for. @@ -787,6 +961,8 @@ The Proxy Service allows you to configure actions for your domains beyond DNS co - `create_invalidation()` - Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. 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. - `list_rules()` - Get a list of all the proxy rules. You can use the query params to filter your results. - `create_api_rule()` - Create a new proxy rule for serving Appwrite's API on custom domain. @@ -877,7 +1053,7 @@ The TablesDB service allows you to create structured tables of columns, query an - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -946,6 +1122,8 @@ The TablesDB service allows you to create structured tables of columns, query an - `update_polygon_column()` - Update a polygon column. Changing the `default` value will not update already existing rows. - `create_relationship_column()` - Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). +- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + - `create_string_column()` - Create a string column. - `update_string_column()` - Update a string column. Changing the `default` value will not update already existing rows. @@ -964,11 +1142,9 @@ The TablesDB service allows you to create structured tables of columns, query an - `get_column()` - Get column by ID. - `delete_column()` - Deletes a column. -- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - - `list_indexes()` - List indexes on the table. - `create_index()` - Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. - `get_index()` - Get index by ID. - `delete_index()` - Delete an index. - `list_rows()` - Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -1041,13 +1217,12 @@ The Users service allows you to manage your project users. - `get()` - Get a user by its unique ID. - `delete()` - Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. - `update_email()` - Update the user email by its unique ID. -- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. 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. - `create_jwt()` - Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. - `update_labels()` - Update the user labels by its unique ID. Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. -- `list_logs()` - Get the user activity logs list by its unique ID. - `list_memberships()` - Get the user membership list by its unique ID. - `update_mfa()` - Enable or disable MFA on a user account. - `update_mfa()` - Enable or disable MFA on a user account. @@ -1063,6 +1238,10 @@ Labels can be used to grant access to resources. While teams are a way for user& - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `update_name()` - Update the user name by its unique ID. +- `list_passkeys()` - Get the list of verified passkeys registered by a user. +- `get_passkey()` - Get a verified passkey of a user by its unique ID. +- `update_passkey()` - Rename a passkey of a user. +- `delete_passkey()` - Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. - `update_password()` - Update the user password by its unique ID. - `update_phone()` - Update the user phone by its unique ID. - `get_prefs()` - Get the user preferences by its unique ID. @@ -1089,7 +1268,7 @@ If you want to generate a token for a custom authentication flow, use the [POST - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -1127,6 +1306,35 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Waf + +- `list_rules()` - List WAF rules for the current project. + +- `create_bypass_rule()` - 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. + +- `update_bypass_rule()` - 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. + +- `create_challenge_rule()` - 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. + +- `update_challenge_rule()` - 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. + +- `create_deny_rule()` - 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. + +- `update_deny_rule()` - 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. + +- `create_rate_limit_rule()` - 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. + +- `update_rate_limit_rule()` - 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. + +- `create_redirect_rule()` - 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. + +- `update_redirect_rule()` - 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. + +- `get_rule()` - Get a WAF rule by its ID. + +- `delete_rule()` - Delete a WAF rule. + + #### Webhooks The Webhooks service allows you to manage your project webhooks. - `list()` - Get a list of all webhooks belonging to the project. You can use the query params to filter your results. @@ -1149,7 +1357,6 @@ The Webhooks service allows you to manage your project webhooks. - `UserList` - Users List - `SessionList` - Sessions List - `IdentityList` - Identities List -- `LogList` - Logs List - `FileList` - Files List - `BucketList` - Buckets List - `ResourceTokenList` - Resource Tokens List @@ -1236,7 +1443,6 @@ The Webhooks service allows you to manage your project webhooks. - `Row` - Row - `Document` - Document - `Presence` - Presence -- `Log` - Log - `User` - User - `AlgoMd5` - AlgoMD5 - `AlgoSha` - AlgoSHA @@ -1245,6 +1451,7 @@ The Webhooks service allows you to manage your project webhooks. - `AlgoScrypt` - AlgoScrypt - `AlgoScryptModified` - AlgoScryptModified - `AlgoArgon2` - AlgoArgon2 +- `Account` - Account - `Preferences` - Preferences - `Session` - Session - `Identity` - Identity @@ -1271,7 +1478,6 @@ The Webhooks service allows you to manage your project webhooks. - `Webhook` - Webhook - `Key` - Key - `EphemeralKey` - Ephemeral Key -- `DevKey` - DevKey - `MockNumber` - Mock Number - `OAuth2Github` - OAuth2GitHub - `OAuth2Discord` - OAuth2Discord @@ -1288,6 +1494,7 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Yandex` - OAuth2Yandex - `OAuth2X` - OAuth2X - `OAuth2WordPress` - OAuth2WordPress +- `OAuth2Webflow` - OAuth2Webflow - `OAuth2Twitch` - OAuth2Twitch - `OAuth2Stripe` - OAuth2Stripe - `OAuth2Spotify` - OAuth2Spotify @@ -1317,11 +1524,15 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Apple` - OAuth2Apple - `OAuth2Microsoft` - OAuth2Microsoft - `OAuth2Resend` - OAuth2Resend +- `OAuth2TikTok` - OAuth2TikTok +- `OAuth2Kakao` - OAuth2Kakao - `OAuth2ProviderList` - OAuth2 Providers List - `PolicyPasswordDictionary` - Policy Password Dictionary - `PolicyPasswordHistory` - Policy Password History - `PolicyPasswordStrength` - Policy Password Strength - `PolicyPasswordPersonalData` - Policy Password Personal Data +- `PolicyPasswordPwned` - Policy Password Pwned +- `PolicyPasswordRotation` - Policy Password Rotation - `PolicySessionAlert` - Policy Session Alert - `PolicySessionDuration` - Policy Session Duration - `PolicySessionInvalidation` - Policy Session Invalidation @@ -1329,6 +1540,11 @@ The Webhooks service allows you to manage your project webhooks. - `PolicyUserLimit` - Policy User Limit - `PolicyMembershipPrivacy` - Policy Membership Privacy - `PolicyMfaFactors` - Policy MFA Factors +- `PolicyPasskey` - Policy Passkey +- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email +- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email +- `PolicyDenyFreeEmail` - Policy Deny Free Email +- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `PlatformWeb` - Platform Web - `PlatformApple` - Platform Apple - `PlatformAndroid` - Platform Android @@ -1347,6 +1563,10 @@ The Webhooks service allows you to manage your project webhooks. - `EmailTemplate` - EmailTemplate - `MfaChallenge` - MFA Challenge - `MfaChallengeSecret` - MFA Challenge Secret +- `TokenSecret` - Token Secret +- `Passkey` - Passkey +- `PasskeyChallenge` - Passkey Challenge +- `PasskeyList` - Passkeys List - `MfaRecoveryCodes` - MFA Recovery Codes - `MfaType` - MFAType - `MfaFactors` - MFAFactors @@ -1381,6 +1601,10 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseExecutionColumn` - ExecutionColumn - `DedicatedDatabaseRestoration` - Restoration - `DatabaseStatus` - Status +- `DnsRecord` - DNSRecord +- `Domain` - Domain +- `DomainPrice` - DomainPrice +- `DomainTransferStatus` - domainTransferStatus - `DedicatedDatabaseExtensions` - Extensions - `DedicatedDatabaseMember` - Member - `DedicatedDatabaseOperation` - Operation @@ -1390,10 +1614,6 @@ The Webhooks service allows you to manage your project webhooks. - `Organization` - Organization - `DedicatedDatabasePITRWindows` - PITRWindows - `BackupPolicy` - backup -- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email -- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email -- `PolicyDenyFreeEmail` - Policy Deny Free Email -- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `DedicatedDatabasePooler` - PoolerConfig - `PostgresExtension` - Postgres extension - `Program` - Program @@ -1401,7 +1621,6 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseRestorationList` - Dedicated database restorations list - `DedicatedDatabaseSpecification` - Specification - `DedicatedDatabaseSpecificationList` - SpecificationList -- `DedicatedDatabaseSpecificationPricing` - SpecificationPricing - `DatabaseStatusConnections` - Connections - `DatabaseStatusReplica` - Replica - `DatabaseStatusVolume` - Volume @@ -1419,8 +1638,15 @@ The Webhooks service allows you to manage your project webhooks. - `Oauth2DeviceAuthorization` - OAuth2 Device Authorization - `Oauth2PAR` - OAuth2 PAR - `Oauth2Token` - OAuth2 Token +- `Oauth2Introspection` - OAuth2 Introspection - `Oauth2Consent` - OAuth2 Consent - `Oauth2ConsentToken` - OAuth2 Consent Token +- `WafRuleBypass` - WafRuleBypass +- `WafRuleDeny` - WafRuleDeny +- `WafRuleChallenge` - WafRuleChallenge +- `WafRuleRateLimit` - WafRuleRateLimit +- `WafRuleRedirect` - WafRuleRedirect +- `WafRuleList` - WAF rule list - `Oauth2Project` - OAuth2 Project - `Oauth2Organization` - OAuth2 Organization - `Oauth2ProjectList` - OAuth2 accessible projects list @@ -1433,6 +1659,9 @@ The Webhooks service allows you to manage your project webhooks. - `BackupRestorationList` - Backup restoration list - `DatabaseMigrationList` - Database Migrations List - `DedicatedDatabaseList` - Dedicated databases list +- `DnsRecordsList` - DNS records list +- `DomainPricesList` - Domain prices list +- `DomainsList` - Domains list - `AppsList` - Apps list - `AppSecretList` - App secrets list - `AppScopeList` - App scopes list @@ -1453,4 +1682,4 @@ The Webhooks service allows you to manage your project webhooks. - File upload examples - Query builder documentation -[0.16.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.16.0 +[0.20.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.20.0 diff --git a/Cargo.toml b/Cargo.toml index b5198a4..784ba2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "appwrite" -version = "0.19.0" +version = "0.20.0" edition = "2021" rust-version = "1.83" authors = ["appwrite"] diff --git a/README.md b/README.md index 3b784e1..26523cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Appwrite Rust SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-rust.svg) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg) [![Crates.io](https://img.shields.io/crates/v/appwrite.svg)](https://crates.io/crates/appwrite) [![Documentation](https://docs.rs/appwrite/badge.svg)](https://docs.rs/appwrite) -**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-rust/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-rust/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 Rust 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) @@ -17,7 +17,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -appwrite = "0.19.0" +appwrite = "0.20.0" tokio = { version = "1.48", features = ["full"] } ``` diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index a6f2987..6314ff5 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent_token( + account.delete_consent_token( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index 084f1c6..c850bcd 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent( + account.delete_consent( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 8f332bf..0000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,23 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Account; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_session(""); // The user session to authenticate with - - let account = Account::new(&client); - - let result = account.list_logs( - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index 320dac4..8abf001 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_installation( + apps.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index 1d3bf37..2b3c9ae 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_key( + apps.delete_key( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index 1fa363c..86ba5da 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_secret( + apps.delete_secret( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index febc173..dc71045 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_tokens( + apps.delete_tokens( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index 84d8cfd..ab57e98 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete( + apps.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index d75868a..5929752 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_archive( + backups.delete_archive( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index 05e44f4..2368cc2 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_policy( + backups.delete_policy( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index f469178..249a02f 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index b7389d9..8e7aeef 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DatabasesIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 2d75876..7642b78 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 6ef035f..e37391a 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1c60d5c..5154b92 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index 2b7534c..3ace295 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DocumentsDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index be2ad02..f2807ca 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index d6ba165..40e58ed 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 8f945bb..de4f2e5 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let embeddings = Embeddings::new(&client); let result = embeddings.create_text_embeddings( - vec![], + vec!["Appwrite helps developers build applications.".into(), "Find documents with semantic search.".into()], Some(appwrite::enums::EmbeddingModel::NomicEmbedText) // optional ).await?; diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 2a28b83..0746b1e 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = messaging.create_twilio_provider( "", "", - Some("+12065550100"), // optional + Some(""), // optional Some(""), // optional Some(""), // optional Some(false) // optional diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md index 9114d69..05d5d23 100644 --- a/docs/examples/mongo/delete-backup-policy.md +++ b/docs/examples/mongo/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup_policy( + mongo.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md index d596d40..b992f13 100644 --- a/docs/examples/mongo/delete-backup.md +++ b/docs/examples/mongo/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup( + mongo.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md index 777f263..3f9734f 100644 --- a/docs/examples/mongo/delete.md +++ b/docs/examples/mongo/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete( + mongo.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md index 39ae07e..2e859af 100644 --- a/docs/examples/mysql/delete-backup-policy.md +++ b/docs/examples/mysql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup_policy( + mysql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md index 2e0b931..40b6302 100644 --- a/docs/examples/mysql/delete-backup.md +++ b/docs/examples/mysql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup( + mysql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md index db5d332..ab8b4b9 100644 --- a/docs/examples/mysql/delete.md +++ b/docs/examples/mysql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete( + mysql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index ff39bf6..ee6c153 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 2593e9b..45ada9f 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index db2c875..3a93e0b 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index c894372..a026965 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index a208289..6bf1198 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 3e344a2..f334c66 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index eecf973..8bc0d41 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some("https://example.com"), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index fbd475d..8270c93 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index c440370..6f32686 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 30c6e9f..d21afc2 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index a303692..645c41d 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 9469837..638b47e 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 5ec24d8..0000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.create_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index d4cb99d..af3dc97 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let organization = Organization::new(&client); - let result = organization.delete_installation( + organization.delete_installation( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md deleted file mode 100644 index 34a1e1b..0000000 --- a/docs/examples/organization/delete-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - organization.delete_key( - "" - ).await?; - - Ok(()) -} -``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md deleted file mode 100644 index 2d01434..0000000 --- a/docs/examples/organization/get-key.md +++ /dev/null @@ -1,22 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.get_key( - "" - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md deleted file mode 100644 index 1466645..0000000 --- a/docs/examples/organization/list-keys.md +++ /dev/null @@ -1,23 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.list_keys( - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index a798005..0000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.update_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md index 1362635..4eeef55 100644 --- a/docs/examples/postgresql/delete-backup-policy.md +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup_policy( + postgresql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md index f30ba45..f5ba8fd 100644 --- a/docs/examples/postgresql/delete-backup.md +++ b/docs/examples/postgresql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup( + postgresql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md index 4d9207e..8a966ce 100644 --- a/docs/examples/postgresql/delete.md +++ b/docs/examples/postgresql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete( + postgresql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 93d1dc4..357e4d6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.create_ephemeral_key( - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], 600 ).await?; diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index cb5f2ce..a62073f 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); project.create_smtp_test( - vec![] + vec!["recipient@example.com".into()] ).await?; Ok(()) diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 12b0282..1c6148a 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = project.update_key( "", "", - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], Some("2020-10-15T06:38:00.000+00:00") // optional ).await?; diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index 541993e..e9b0ea4 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.update_labels( - vec![] + vec!["production".into()] ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index f96eb6e..4f8dbdd 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,8 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_kakao( Some(""), // optional Some(""), // optional - Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 7e5d915..d837d4e 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let sites = Sites::new(&client); - let result = sites.delete_log( + sites.delete_log( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 409d88d..725a771 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::TablesDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index b5722c4..86e0b5c 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 36606d6..d3ebd3d 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let tables_db = TablesDB::new(&client); - let result = tables_db.delete_migration( + tables_db.delete_migration( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 92520ae..e1fe9bc 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.delete_rows( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index ba84a60..94e26a9 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.upsert_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index bb83298..14400af 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = teams.create_membership( "", - vec![], + vec!["editor".into()], Some("email@example.com"), // optional Some(""), // optional Some("+12065550100"), // optional diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index b635b14..6af98a5 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let teams = Teams::new(&client); - let result = teams.delete_installation( + teams.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 6c6d0d7..512671a 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = teams.update_membership( "", "", - vec![] + vec!["editor".into()] ).await?; let _ = result; diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md deleted file mode 100644 index 6f5b333..0000000 --- a/docs/examples/users/list-logs.md +++ /dev/null @@ -1,24 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Users; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let users = Users::new(&client); - - let result = users.list_logs( - "", - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 00922e3..9305ebb 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = users.update_labels( "", - vec![] + vec!["subscriber".into()] ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index 1010288..f539c40 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - 1, + 4, Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index d2aff1f..b8c30b6 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index 02d30e2..f686c4e 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::VectorsDBIndexType::HnswEuclidean, - vec![], + vec!["embeddings".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index cc1aaca..bc8db2b 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_operations( "", - Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"name":"Walter O'Brien"}})]) // optional + Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}}})]) // optional ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index a69a6a7..fc80819 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 86309ba..4256276 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - Some(1), // optional + Some(4), // optional Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index c556118..5f120e9 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index a14a6c1..2862ee9 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "https://example.com/webhook", "", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 73d636d..407ea25 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "", "https://example.com/webhook", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/src/client.rs b/src/client.rs index 946094f..7d44b79 100644 --- a/src/client.rs +++ b/src/client.rs @@ -59,6 +59,12 @@ impl Default for UploadOptions { } } +#[derive(Debug, Clone, Copy)] +enum ResponseFormat { + Json, + Text, +} + /// Appwrite client for making API requests #[derive(Debug, Clone)] pub struct Client { @@ -91,11 +97,11 @@ impl Client { /// Create a new Appwrite client pub fn new() -> Self { let mut headers = HeaderMap::new(); - headers.insert("X-Appwrite-Response-Format", "2.0.0".parse().unwrap()); + headers.insert("X-Appwrite-Response-Format", "2.5.0".parse().unwrap()); headers.insert( "user-agent", format!( - "AppwriteRustSDK/0.19.0 ({}; {})", + "AppwriteRustSDK/0.20.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH ) @@ -105,7 +111,7 @@ impl Client { headers.insert("x-sdk-name", "Rust".parse().unwrap()); headers.insert("x-sdk-platform", "server".parse().unwrap()); headers.insert("x-sdk-language", "rust".parse().unwrap()); - headers.insert("x-sdk-version", "0.19.0".parse().unwrap()); + headers.insert("x-sdk-version", "0.20.0".parse().unwrap()); let config = Config { endpoint: "https://cloud.appwrite.io/v1".to_string(), @@ -289,21 +295,6 @@ impl Client { self.clone() } - /// Set DevKey - /// - /// Your secret dev API key - pub fn set_dev_key>(&self, value: S) -> Self { - let value = value.into(); - self.state.rcu(|state| { - let mut next = (**state).clone(); - next.config - .headers - .insert("x-appwrite-dev-key", value.clone().parse().unwrap()); - Arc::new(next) - }); - self.clone() - } - /// Set Cookie /// /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -554,36 +545,27 @@ impl Client { headers: Option>, params: Option>, ) -> Result { - let response = self.request(method, path, headers, params).await?; - self.handle_response(response).await - } - - /// Make an API call that returns a plain-text body as a UTF-8 string - pub async fn call_text( - &self, - method: Method, - path: &str, - headers: Option>, - params: Option>, - ) -> Result { - let response = self.request(method, path, headers, params).await?; - if response.status().is_success() { - return Ok(response.text().await?); - } - self.handle_response::(response) + self.send(method, path, headers, params, ResponseFormat::Json) .await - .map(|_| String::new()) } - async fn request( + async fn send( &self, method: Method, path: &str, headers: Option>, params: Option>, - ) -> Result { + format: ResponseFormat, + ) -> Result { let state = self.state.load_full(); let url = format!("{}{}", state.config.endpoint, path); + let is_multipart = method != Method::GET + && headers.as_ref().is_some_and(|headers| { + headers.iter().any(|(key, value)| { + key.eq_ignore_ascii_case("content-type") + && value.eq_ignore_ascii_case("multipart/form-data") + }) + }); let mut request_builder; if let Some(params) = params { @@ -600,21 +582,36 @@ impl Client { request_builder = state.http.request(method.clone(), url_with_params); } else { request_builder = state.http.request(method.clone(), &url); - request_builder = request_builder.json(¶ms); + if is_multipart { + let mut form = multipart::Form::new(); + for (key, value) in Self::flatten_multipart_params(¶ms, "") { + form = form.text(key, value); + } + request_builder = request_builder.multipart(form); + } else { + request_builder = request_builder.json(¶ms); + } } } else { request_builder = state.http.request(method.clone(), &url); } - request_builder = request_builder.headers(state.config.headers.clone()); + let mut default_headers = state.config.headers.clone(); + if is_multipart { + default_headers.remove("content-type"); + } + request_builder = request_builder.headers(default_headers); if let Some(custom_headers) = headers { for (key, value) in custom_headers { - request_builder = request_builder.header(key, value); + if !is_multipart || !key.eq_ignore_ascii_case("content-type") { + request_builder = request_builder.header(key, value); + } } } - Ok(request_builder.send().await?) + let response = request_builder.send().await?; + self.handle_response(response, format).await } /// Make an API call that returns a location/redirect URL (for webAuth endpoints) @@ -801,7 +798,19 @@ impl Client { } } - /// Upload a file + /// Make an API call that returns a plain-text body as a UTF-8 string + pub async fn call_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: Option>, + ) -> Result { + self.send(method, path, headers, params, ResponseFormat::Text) + .await + } + + /// Upload a file with POST pub async fn file_upload( &self, path: &str, @@ -824,7 +833,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method - #[allow(clippy::too_many_arguments)] pub async fn upload( &self, method: Method, @@ -851,7 +859,69 @@ impl Client { .await } - /// Upload a file with progress callback + /// Upload a file in one request whatever the configured chunk size, for + /// endpoints that do not accept chunked uploads + pub async fn single_upload( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) + .await + } + + /// Upload a file with POST and return the plain-text response body + pub async fn file_upload_text( + &self, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + self.upload_text(Method::POST, path, headers, params, param_name, input_file) + .await + } + + /// Upload a file with the endpoint's HTTP method and return the plain-text response body + pub async fn upload_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Text, + ) + .await + } + + /// Upload a file with POST and a progress callback pub async fn file_upload_with_progress( &self, path: &str, @@ -877,7 +947,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method and a progress callback - #[allow(clippy::too_many_arguments)] pub async fn upload_with_progress( &self, method: Method, @@ -902,7 +971,15 @@ impl Client { let url = format!("{}{}", state.config.endpoint, path); let result = self - .single_file_upload(method, &url, headers, params, param_name, &input_file) + .single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) .await?; if let Some(callback) = &options.on_progress { @@ -929,22 +1006,6 @@ impl Client { .await } - /// Upload a file in one request, whatever the configured chunk size, for - /// endpoints that do not accept chunked uploads - pub(crate) async fn single_upload( - &self, - method: Method, - path: &str, - headers: Option>, - params: HashMap, - param_name: &str, - input_file: InputFile, - ) -> Result { - let url = format!("{}{}", self.state.load_full().config.endpoint, path); - self.single_file_upload(method, &url, headers, params, param_name, &input_file) - .await - } - async fn single_file_upload( &self, method: Method, @@ -953,6 +1014,7 @@ impl Client { params: HashMap, param_name: &str, input_file: &InputFile, + format: ResponseFormat, ) -> Result { let state = self.state.load_full(); let mut form = multipart::Form::new(); @@ -997,10 +1059,9 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, format).await } - #[allow(clippy::too_many_arguments)] async fn chunked_file_upload_with_progress( &self, method: Method, @@ -1099,6 +1160,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1106,7 +1168,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1160,6 +1221,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1167,7 +1229,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1279,10 +1340,14 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, ResponseFormat::Json).await } - async fn handle_response(&self, response: Response) -> Result { + async fn handle_response( + &self, + response: Response, + format: ResponseFormat, + ) -> Result { let status = response.status(); let content_type = response .headers() @@ -1295,6 +1360,19 @@ impl Client { if status.is_success() { let bytes = response.bytes().await?; + if let ResponseFormat::Text = format { + let text = String::from_utf8(bytes.to_vec()).map_err(|e| { + AppwriteError::new( + 0, + format!("Invalid UTF-8 response: {}", e), + None, + String::from_utf8_lossy(e.as_bytes()).to_string(), + ) + })?; + + return Ok(serde_json::from_value(Value::String(text))?); + } + if !content_type.is_empty() && !content_type.starts_with("application/json") && !bytes.is_empty() diff --git a/src/enums/billing_plan_group.rs b/src/enums/billing_plan_group.rs index 9557243..e8b9ed3 100644 --- a/src/enums/billing_plan_group.rs +++ b/src/enums/billing_plan_group.rs @@ -2,10 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum BillingPlanGroup { - #[serde(rename = "starter")] - #[default] - Starter, #[serde(rename = "free")] + #[default] Free, #[serde(rename = "start")] Start, @@ -19,7 +17,6 @@ impl BillingPlanGroup { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { - BillingPlanGroup::Starter => "starter", BillingPlanGroup::Free => "free", BillingPlanGroup::Start => "start", BillingPlanGroup::Pro => "pro", diff --git a/src/enums/execution_method.rs b/src/enums/execution_method.rs index 6764169..5dc4639 100644 --- a/src/enums/execution_method.rs +++ b/src/enums/execution_method.rs @@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ExecutionMethod { #[serde(rename = "GET")] - #[default] GET, #[serde(rename = "POST")] + #[default] POST, #[serde(rename = "PUT")] PUT, diff --git a/src/enums/image_gravity.rs b/src/enums/image_gravity.rs index 202aa5e..5114a01 100644 --- a/src/enums/image_gravity.rs +++ b/src/enums/image_gravity.rs @@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ImageGravity { + #[serde(rename = "auto")] + Auto, #[serde(rename = "center")] #[default] Center, @@ -21,14 +23,13 @@ pub enum ImageGravity { Bottom, #[serde(rename = "bottom-right")] BottomRight, - #[serde(rename = "auto")] - Auto, } impl ImageGravity { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { + ImageGravity::Auto => "auto", ImageGravity::Center => "center", ImageGravity::TopLeft => "top-left", ImageGravity::Top => "top", @@ -38,7 +39,6 @@ impl ImageGravity { ImageGravity::BottomLeft => "bottom-left", ImageGravity::Bottom => "bottom", ImageGravity::BottomRight => "bottom-right", - ImageGravity::Auto => "auto", } } } diff --git a/src/enums/mod.rs b/src/enums/mod.rs index 91c4db1..58377e5 100644 --- a/src/enums/mod.rs +++ b/src/enums/mod.rs @@ -54,8 +54,6 @@ pub mod message_priority; pub use message_priority::MessagePriority; pub mod smtp_encryption; pub use smtp_encryption::SmtpEncryption; -pub mod organization_key_scopes; -pub use organization_key_scopes::OrganizationKeyScopes; pub mod region; pub use region::Region; pub mod project_auth_method_id; diff --git a/src/enums/organization_key_scopes.rs b/src/enums/organization_key_scopes.rs deleted file mode 100644 index 7844c9b..0000000 --- a/src/enums/organization_key_scopes.rs +++ /dev/null @@ -1,72 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] -pub enum OrganizationKeyScopes { - #[serde(rename = "projects.read")] - #[default] - ProjectsRead, - #[serde(rename = "projects.write")] - ProjectsWrite, - #[serde(rename = "devKeys.read")] - DevKeysRead, - #[serde(rename = "devKeys.write")] - DevKeysWrite, - #[serde(rename = "organization.keys.read")] - OrganizationKeysRead, - #[serde(rename = "organization.keys.write")] - OrganizationKeysWrite, - #[serde(rename = "organization.installations.read")] - OrganizationInstallationsRead, - #[serde(rename = "organization.installations.write")] - OrganizationInstallationsWrite, - #[serde(rename = "organization.memberships.read")] - OrganizationMembershipsRead, - #[serde(rename = "organization.memberships.write")] - OrganizationMembershipsWrite, - #[serde(rename = "organization.read")] - OrganizationRead, - #[serde(rename = "organization.write")] - OrganizationWrite, - #[serde(rename = "domains.read")] - DomainsRead, - #[serde(rename = "domains.write")] - DomainsWrite, - #[serde(rename = "keys.read")] - KeysRead, - #[serde(rename = "keys.write")] - KeysWrite, -} - -impl OrganizationKeyScopes { - /// Get the string value of the enum - pub fn as_str(&self) -> &str { - match self { - OrganizationKeyScopes::ProjectsRead => "projects.read", - OrganizationKeyScopes::ProjectsWrite => "projects.write", - OrganizationKeyScopes::DevKeysRead => "devKeys.read", - OrganizationKeyScopes::DevKeysWrite => "devKeys.write", - OrganizationKeyScopes::OrganizationKeysRead => "organization.keys.read", - OrganizationKeyScopes::OrganizationKeysWrite => "organization.keys.write", - OrganizationKeyScopes::OrganizationInstallationsRead => { - "organization.installations.read" - } - OrganizationKeyScopes::OrganizationInstallationsWrite => { - "organization.installations.write" - } - OrganizationKeyScopes::OrganizationMembershipsRead => "organization.memberships.read", - OrganizationKeyScopes::OrganizationMembershipsWrite => "organization.memberships.write", - OrganizationKeyScopes::OrganizationRead => "organization.read", - OrganizationKeyScopes::OrganizationWrite => "organization.write", - OrganizationKeyScopes::DomainsRead => "domains.read", - OrganizationKeyScopes::DomainsWrite => "domains.write", - OrganizationKeyScopes::KeysRead => "keys.read", - OrganizationKeyScopes::KeysWrite => "keys.write", - } - } -} - -impl std::fmt::Display for OrganizationKeyScopes { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.as_str()) - } -} diff --git a/src/lib.rs b/src/lib.rs index 25914d9..d203e37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```toml //! [dependencies] -//! appwrite = "0.19.0" +//! appwrite = "0.20.0" //! ``` //! //! ## Usage @@ -51,7 +51,7 @@ pub use input_file::InputFile; pub type Result = std::result::Result; /// SDK version -pub const VERSION: &str = "0.19.0"; +pub const VERSION: &str = "0.20.0"; /// SDK name pub const SDK_NAME: &str = "Rust"; diff --git a/src/models/activity_event.rs b/src/models/activity_event.rs index 5590142..b488871 100644 --- a/src/models/activity_event.rs +++ b/src/models/activity_event.rs @@ -8,93 +8,238 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEvent { /// Event ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Actor type. #[serde(rename = "actorType")] + #[serde(default = "default_actor_type")] pub actor_type: String, /// Actor ID. #[serde(rename = "actorId")] + #[serde(default = "default_actor_id")] pub actor_id: String, /// Actor Email. #[serde(rename = "actorEmail")] + #[serde(default = "default_actor_email")] pub actor_email: String, /// Actor Name. #[serde(rename = "actorName")] + #[serde(default = "default_actor_name")] pub actor_name: String, /// Resource parent. #[serde(rename = "resourceParent")] + #[serde(default = "default_resource_parent")] pub resource_parent: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource. #[serde(rename = "resource")] + #[serde(default = "default_resource")] pub resource: String, /// Event name. #[serde(rename = "event")] + #[serde(default = "default_event")] pub event: String, /// User agent. #[serde(rename = "userAgent")] + #[serde(default = "default_user_agent")] pub user_agent: String, /// IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// API mode when event triggered. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Location. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// City name. #[serde(rename = "city")] + #[serde(default = "default_city")] pub city: String, /// Region/state chain. #[serde(rename = "subdivisions")] + #[serde(default = "default_subdivisions")] pub subdivisions: String, /// Internet service provider. #[serde(rename = "isp")] + #[serde(default = "default_isp")] pub isp: String, /// Autonomous System Number (ASN). #[serde(rename = "autonomousSystemNumber")] + #[serde(default = "default_autonomous_system_number")] pub autonomous_system_number: String, /// Organization that owns the ASN. #[serde(rename = "autonomousSystemOrganization")] + #[serde(default = "default_autonomous_system_organization")] pub autonomous_system_organization: String, /// Connection type (e.g. cable, cellular, corporate). #[serde(rename = "connectionType")] + #[serde(default = "default_connection_type")] pub connection_type: String, /// User type (e.g. residential, business, hosting). #[serde(rename = "connectionUsageType")] + #[serde(default = "default_connection_usage_type")] pub connection_usage_type: String, /// Registered organization of the IP. #[serde(rename = "connectionOrganization")] + #[serde(default = "default_connection_organization")] pub connection_organization: String, /// Log creation date in ISO 8601 format. #[serde(rename = "time")] + #[serde(default = "default_time")] pub time: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Hostname. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Name of the SDK that triggered the event. #[serde(rename = "sdk")] + #[serde(default = "default_sdk")] pub sdk: String, /// Version of the SDK that triggered the event. #[serde(rename = "sdkVersion")] + #[serde(default = "default_sdk_version")] pub sdk_version: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_actor_type() -> String { + "".to_string() +} + +fn default_actor_id() -> String { + "".to_string() +} + +fn default_actor_email() -> String { + "".to_string() +} + +fn default_actor_name() -> String { + "".to_string() +} + +fn default_resource_parent() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource() -> String { + "".to_string() +} + +fn default_event() -> String { + "".to_string() +} + +fn default_user_agent() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_mode() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_city() -> String { + "".to_string() +} + +fn default_subdivisions() -> String { + "".to_string() +} + +fn default_isp() -> String { + "".to_string() +} + +fn default_autonomous_system_number() -> String { + "".to_string() +} + +fn default_autonomous_system_organization() -> String { + "".to_string() +} + +fn default_connection_type() -> String { + "".to_string() +} + +fn default_connection_usage_type() -> String { + "".to_string() +} + +fn default_connection_organization() -> String { + "".to_string() +} + +fn default_time() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_sdk() -> String { + "".to_string() +} + +fn default_sdk_version() -> String { + "".to_string() +} + impl ActivityEvent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/activity_event_list.rs b/src/models/activity_event_list.rs index a83d557..ff7cf56 100644 --- a/src/models/activity_event_list.rs +++ b/src/models/activity_event_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEventList { /// Total number of events that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ActivityEventList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/additional_resource.rs b/src/models/additional_resource.rs index bf02523..8f5d252 100644 --- a/src/models/additional_resource.rs +++ b/src/models/additional_resource.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct AdditionalResource { /// Resource name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Resource unit #[serde(rename = "unit")] + #[serde(default = "default_unit")] pub unit: String, /// Price currency #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_unit() -> String { + "".to_string() +} + +fn default_currency() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl AdditionalResource { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/algo_argon2.rs b/src/models/algo_argon2.rs index c4e4c7e..490a220 100644 --- a/src/models/algo_argon2.rs +++ b/src/models/algo_argon2.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoArgon2 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Memory used to compute hash. #[serde(rename = "memoryCost")] + #[serde(default = "default_memory_cost")] pub memory_cost: i64, /// Amount of time consumed to compute hash #[serde(rename = "timeCost")] + #[serde(default = "default_time_cost")] pub time_cost: i64, /// Number of threads used to compute hash. #[serde(rename = "threads")] + #[serde(default = "default_threads")] pub threads: i64, } +fn default_type() -> String { + "argon2".to_string() +} + +fn default_memory_cost() -> i64 { + 0 +} + +fn default_time_cost() -> i64 { + 0 +} + +fn default_threads() -> i64 { + 0 +} + impl AlgoArgon2 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_bcrypt.rs b/src/models/algo_bcrypt.rs index acbd333..93c307f 100644 --- a/src/models/algo_bcrypt.rs +++ b/src/models/algo_bcrypt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoBcrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "bcrypt".to_string() +} + impl AlgoBcrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_md5.rs b/src/models/algo_md5.rs index babd088..3f75ba8 100644 --- a/src/models/algo_md5.rs +++ b/src/models/algo_md5.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoMd5 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "md5".to_string() +} + impl AlgoMd5 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_phpass.rs b/src/models/algo_phpass.rs index 8227738..0a9f876 100644 --- a/src/models/algo_phpass.rs +++ b/src/models/algo_phpass.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoPhpass { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "phpass".to_string() +} + impl AlgoPhpass { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt.rs b/src/models/algo_scrypt.rs index 86a424a..18c4bce 100644 --- a/src/models/algo_scrypt.rs +++ b/src/models/algo_scrypt.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// CPU complexity of computed hash. #[serde(rename = "costCpu")] + #[serde(default = "default_cost_cpu")] pub cost_cpu: i64, /// Memory complexity of computed hash. #[serde(rename = "costMemory")] + #[serde(default = "default_cost_memory")] pub cost_memory: i64, /// Parallelization of computed hash. #[serde(rename = "costParallel")] + #[serde(default = "default_cost_parallel")] pub cost_parallel: i64, /// Length used to compute hash. #[serde(rename = "length")] + #[serde(default = "default_length")] pub length: i64, } +fn default_type() -> String { + "scrypt".to_string() +} + +fn default_cost_cpu() -> i64 { + 8 +} + +fn default_cost_memory() -> i64 { + 14 +} + +fn default_cost_parallel() -> i64 { + 1 +} + +fn default_length() -> i64 { + 64 +} + impl AlgoScrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt_modified.rs b/src/models/algo_scrypt_modified.rs index 3722ebd..35cd10c 100644 --- a/src/models/algo_scrypt_modified.rs +++ b/src/models/algo_scrypt_modified.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScryptModified { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Salt used to compute hash. #[serde(rename = "salt")] + #[serde(default = "default_salt")] pub salt: String, /// Separator used to compute hash. #[serde(rename = "saltSeparator")] + #[serde(default = "default_salt_separator")] pub salt_separator: String, /// Key used to compute hash. #[serde(rename = "signerKey")] + #[serde(default = "default_signer_key")] pub signer_key: String, } +fn default_type() -> String { + "scryptMod".to_string() +} + +fn default_salt() -> String { + "".to_string() +} + +fn default_salt_separator() -> String { + "".to_string() +} + +fn default_signer_key() -> String { + "".to_string() +} + impl AlgoScryptModified { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_sha.rs b/src/models/algo_sha.rs index e8aa8fb..f3af46d 100644 --- a/src/models/algo_sha.rs +++ b/src/models/algo_sha.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoSha { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "sha".to_string() +} + impl AlgoSha { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/app.rs b/src/models/app.rs index 35791b2..3ed9196 100644 --- a/src/models/app.rs +++ b/src/models/app.rs @@ -8,95 +8,225 @@ use serde::{Deserialize, Serialize}; pub struct App { /// App ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Application description shown to users during OAuth2 consent. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Application homepage URL shown to users during OAuth2 consent. #[serde(rename = "clientUri")] + #[serde(default = "default_client_uri")] pub client_uri: String, /// Application logo URL shown to users during OAuth2 consent. #[serde(rename = "logoUri")] + #[serde(default = "default_logo_uri")] pub logo_uri: String, /// Application privacy policy URL shown to users during OAuth2 consent. #[serde(rename = "privacyPolicyUrl")] + #[serde(default = "default_privacy_policy_url")] pub privacy_policy_url: String, /// Application terms of service URL shown to users during OAuth2 consent. #[serde(rename = "termsUrl")] + #[serde(default = "default_terms_url")] pub terms_url: String, /// Application support or security contact emails. #[serde(rename = "contacts")] + #[serde(default = "default_contacts")] pub contacts: Vec, /// Application tagline shown to users during OAuth2 consent. #[serde(rename = "tagline")] + #[serde(default = "default_tagline")] pub tagline: String, /// Application tags shown to users during OAuth2 consent. #[serde(rename = "tags")] + #[serde(default = "default_tags")] pub tags: Vec, /// Application labels. Read-only for clients; only a server SDK using a /// project API key can update them. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Application image URLs shown to users during OAuth2 consent. #[serde(rename = "images")] + #[serde(default = "default_images")] pub images: Vec, /// Application support URL shown to users during OAuth2 consent. #[serde(rename = "supportUrl")] + #[serde(default = "default_support_url")] pub support_url: String, /// Application data deletion URL shown to users during OAuth2 consent. #[serde(rename = "dataDeletionUrl")] + #[serde(default = "default_data_deletion_url")] pub data_deletion_url: String, /// List of authorized redirect URIs. These URIs can be used to redirect users /// after they authenticate. #[serde(rename = "redirectUris")] + #[serde(default = "default_redirect_uris")] pub redirect_uris: Vec, /// List of authorized post-logout redirect URIs for OpenID Connect /// RP-Initiated Logout. The logout endpoint only redirects users to URIs in /// this list after ending their session. #[serde(rename = "postLogoutRedirectUris")] + #[serde(default = "default_post_logout_redirect_uris")] pub post_logout_redirect_uris: Vec, /// Whether the app is enabled or not. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot /// keep a client secret (PKCE required); `confidential` for server-side /// clients that authenticate with a client secret. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Whether this client may use the OAuth2 Device Authorization Grant (RFC /// 8628). #[serde(rename = "deviceFlow")] + #[serde(default = "default_device_flow")] pub device_flow: bool, /// ID of team that owns the application, if owned by team. Otherwise, user ID /// will be used. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// ID of user who owns the application, if owned by user. Otherwise, team ID /// will be used. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Scopes the application requests when installed on a team. /// Organization-level and project-level scopes only. #[serde(rename = "installationScopes")] + #[serde(default = "default_installation_scopes")] pub installation_scopes: Vec, /// URL users are redirected to after creating or updating an installation of /// this application. Empty for no redirect. #[serde(rename = "installationRedirectUrl")] + #[serde(default = "default_installation_redirect_url")] pub installation_redirect_url: String, /// List of application secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_client_uri() -> String { + "".to_string() +} + +fn default_logo_uri() -> String { + "".to_string() +} + +fn default_privacy_policy_url() -> String { + "".to_string() +} + +fn default_terms_url() -> String { + "".to_string() +} + +fn default_contacts() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tagline() -> String { + "".to_string() +} + +fn default_tags() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_images() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_support_url() -> String { + "".to_string() +} + +fn default_data_deletion_url() -> String { + "".to_string() +} + +fn default_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_post_logout_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "confidential".to_string() +} + +fn default_device_flow() -> bool { + false +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_installation_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_installation_redirect_url() -> String { + "".to_string() +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl App { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation.rs b/src/models/app_installation.rs index 7ad4193..970ba93 100644 --- a/src/models/app_installation.rs +++ b/src/models/app_installation.rs @@ -8,34 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallation { /// Installation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Installation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Installation update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the installed application. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// ID of the team the application is installed on. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Scopes granted to the application. Snapshot of the application's /// installation scopes taken when the installation was created or last /// updated. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Authorization details granted to the application. Rich authorization /// request (RFC 9396) style entries; the Appwrite Console stores authorized /// project IDs here. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: Vec, /// ID of the user who created the installation. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the installation. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time an access token was last issued for the installation in ISO 8601 /// format. Null if never used. @@ -44,6 +53,42 @@ pub struct AppInstallation { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppInstallation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation_list.rs b/src/models/app_installation_list.rs index aa427f0..69c156a 100644 --- a/src/models/app_installation_list.rs +++ b/src/models/app_installation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallationList { /// Total number of installations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of installations. #[serde(rename = "installations")] + #[serde(default = "default_installations")] pub installations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_installations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppInstallationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_key.rs b/src/models/app_key.rs index cbfbbd0..4902670 100644 --- a/src/models/app_key.rs +++ b/src/models/app_key.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct AppKey { /// App key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App key creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App key update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this app key belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// App key secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the app key secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the app key. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the app key. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the app key was last used for authentication in ISO 8601 format. Null /// if never used. @@ -37,6 +45,38 @@ pub struct AppKey { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_key_list.rs b/src/models/app_key_list.rs index 232fa6f..d9ca8bb 100644 --- a/src/models/app_key_list.rs +++ b/src/models/app_key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppKeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppKeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_scope.rs b/src/models/app_scope.rs index 7f14082..fcdf744 100644 --- a/src/models/app_scope.rs +++ b/src/models/app_scope.rs @@ -8,23 +8,48 @@ use serde::{Deserialize, Serialize}; pub struct AppScope { /// Scope value as requested by apps. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Human-readable description of what the scope grants. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// What the scope grants access to. One of `account`, `project`, or /// `organization`. Only `project` and `organization` scopes are installable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Scope category, used to group scopes on consent and installation screens. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, /// Whether the scope is deprecated. Deprecated scopes can still be requested /// but should not be offered for new grants. #[serde(rename = "deprecated")] + #[serde(default = "default_deprecated")] pub deprecated: bool, } +fn default_value() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + +fn default_deprecated() -> bool { + false +} + impl AppScope { /// Get value pub fn value(&self) -> &String { diff --git a/src/models/app_scope_list.rs b/src/models/app_scope_list.rs index 0d93b62..cd03802 100644 --- a/src/models/app_scope_list.rs +++ b/src/models/app_scope_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppScopeList { /// Total number of scopes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppScopeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret.rs b/src/models/app_secret.rs index a32282b..43fd6cd 100644 --- a/src/models/app_secret.rs +++ b/src/models/app_secret.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecret { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Always empty. The application client secret is returned only once, in the /// response of the createSecret method. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecret { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_secret_list.rs b/src/models/app_secret_list.rs index f9df34d..23dcef0 100644 --- a/src/models/app_secret_list.rs +++ b/src/models/app_secret_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretList { /// Total number of secrets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppSecretList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret_plaintext.rs b/src/models/app_secret_plaintext.rs index 4c7a292..486d526 100644 --- a/src/models/app_secret_plaintext.rs +++ b/src/models/app_secret_plaintext.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretPlaintext { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Application client secret. Returned only when the secret is created; /// subsequent reads always return an empty value. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecretPlaintext { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecretPlaintext { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/apps_list.rs b/src/models/apps_list.rs index 6f31208..b8c106d 100644 --- a/src/models/apps_list.rs +++ b/src/models/apps_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppsList { /// Total number of apps that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of apps. #[serde(rename = "apps")] + #[serde(default = "default_apps")] pub apps: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_apps() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppsList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_bigint.rs b/src/models/attribute_bigint.rs index 7dffebc..9f298a7 100644 --- a/src/models/attribute_bigint.rs +++ b/src/models/attribute_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBigint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBigint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBigint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_boolean.rs b/src/models/attribute_boolean.rs index e6ddcc3..e08baa3 100644 --- a/src/models/attribute_boolean.rs +++ b/src/models/attribute_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBoolean { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBoolean { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_datetime.rs b/src/models/attribute_datetime.rs index beacd6d..79621c2 100644 --- a/src/models/attribute_datetime.rs +++ b/src/models/attribute_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeDatetime { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeDatetime { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct AttributeDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_email.rs b/src/models/attribute_email.rs index 2f172f7..76dcae3 100644 --- a/src/models/attribute_email.rs +++ b/src/models/attribute_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEmail { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEmail { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeEmail { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl AttributeEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_enum.rs b/src/models/attribute_enum.rs index f78d0eb..620db3a 100644 --- a/src/models/attribute_enum.rs +++ b/src/models/attribute_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEnum { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEnum { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct AttributeEnum { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -46,6 +54,38 @@ pub struct AttributeEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl AttributeEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_float.rs b/src/models/attribute_float.rs index 49cda73..a8467e7 100644 --- a/src/models/attribute_float.rs +++ b/src/models/attribute_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeFloat { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeFloat { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeFloat { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_integer.rs b/src/models/attribute_integer.rs index 39cad56..abb02d0 100644 --- a/src/models/attribute_integer.rs +++ b/src/models/attribute_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeInteger { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeInteger { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeInteger { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_ip.rs b/src/models/attribute_ip.rs index 2328c38..85c4070 100644 --- a/src/models/attribute_ip.rs +++ b/src/models/attribute_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeIp { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeIp { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeIp { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl AttributeIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_line.rs b/src/models/attribute_line.rs index 975994b..670484f 100644 --- a/src/models/attribute_line.rs +++ b/src/models/attribute_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLine { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLine { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLine { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_list.rs b/src/models/attribute_list.rs index d405e6d..73e9346 100644 --- a/src/models/attribute_list.rs +++ b/src/models/attribute_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AttributeList { /// Total number of attributes in the given collection. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AttributeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_longtext.rs b/src/models/attribute_longtext.rs index b613bf1..a45a044 100644 --- a/src/models/attribute_longtext.rs +++ b/src/models/attribute_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLongtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLongtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_mediumtext.rs b/src/models/attribute_mediumtext.rs index 98fcecd..18271f2 100644 --- a/src/models/attribute_mediumtext.rs +++ b/src/models/attribute_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeMediumtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeMediumtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_object.rs b/src/models/attribute_object.rs index 02515bf..ce3af14 100644 --- a/src/models/attribute_object.rs +++ b/src/models/attribute_object.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeObject { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeObject { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,38 @@ pub struct AttributeObject { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeObject { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_point.rs b/src/models/attribute_point.rs index 9ca02a2..d9284e1 100644 --- a/src/models/attribute_point.rs +++ b/src/models/attribute_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePoint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePoint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePoint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_polygon.rs b/src/models/attribute_polygon.rs index 3d39979..59a058b 100644 --- a/src/models/attribute_polygon.rs +++ b/src/models/attribute_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePolygon { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePolygon { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePolygon { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_relationship.rs b/src/models/attribute_relationship.rs index ce0efaf..17b1786 100644 --- a/src/models/attribute_relationship.rs +++ b/src/models/attribute_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeRelationship { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct AttributeRelationship { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related collection. #[serde(rename = "relatedCollection")] pub related_collection: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl AttributeRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_string.rs b/src/models/attribute_string.rs index 93dc8bc..eacad88 100644 --- a/src/models/attribute_string.rs +++ b/src/models/attribute_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeString { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeString { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeString { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_text.rs b/src/models/attribute_text.rs index 838d477..bf666ea 100644 --- a/src/models/attribute_text.rs +++ b/src/models/attribute_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeText { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeText { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeText { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_url.rs b/src/models/attribute_url.rs index 4dfc86c..2305191 100644 --- a/src/models/attribute_url.rs +++ b/src/models/attribute_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeUrl { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeUrl { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeUrl { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl AttributeUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_varchar.rs b/src/models/attribute_varchar.rs index 433fc29..a3277a9 100644 --- a/src/models/attribute_varchar.rs +++ b/src/models/attribute_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVarchar { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeVarchar { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_vector.rs b/src/models/attribute_vector.rs index 2472da9..79dc1c8 100644 --- a/src/models/attribute_vector.rs +++ b/src/models/attribute_vector.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVector { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVector { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,46 @@ pub struct AttributeVector { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Vector dimensions. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVector { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/backup_archive.rs b/src/models/backup_archive.rs index f4811a5..d64dce1 100644 --- a/src/models/backup_archive.rs +++ b/src/models/backup_archive.rs @@ -8,34 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchive { /// Archive ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Archive creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Archive update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Archive policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, - /// Archive size in bytes. + /// Archive size in bytes. Null until the size is known. #[serde(rename = "size")] - pub size: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, /// The status of the archive creation. Possible values: pending, processing, /// uploading, completed, failed, skipped. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The backup start time. Null until the backup starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this archive. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this archive. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this archive should backup a single /// resource. @@ -49,6 +59,38 @@ pub struct BackupArchive { pub resource_type: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchive { /// Get id pub fn id(&self) -> &String { @@ -70,9 +112,15 @@ impl BackupArchive { &self.policy_id } + /// Set size + pub fn set_size(mut self, size: i64) -> Self { + self.size = Some(size); + self + } + /// Get size - pub fn size(&self) -> &i64 { - &self.size + pub fn size(&self) -> Option<&i64> { + self.size.as_ref() } /// Get status @@ -80,9 +128,15 @@ impl BackupArchive { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -134,9 +188,7 @@ mod tests { let _ = _model.created_at(); let _ = _model.updated_at(); let _ = _model.policy_id(); - let _ = _model.size(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_archive_list.rs b/src/models/backup_archive_list.rs index 46af024..6c12aea 100644 --- a/src/models/backup_archive_list.rs +++ b/src/models/backup_archive_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchiveList { /// Total number of archives that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of archives. #[serde(rename = "archives")] + #[serde(default = "default_archives")] pub archives: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_archives() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchiveList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_policy.rs b/src/models/backup_policy.rs index 0ee8535..5c2c5a7 100644 --- a/src/models/backup_policy.rs +++ b/src/models/backup_policy.rs @@ -8,21 +8,27 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicy { /// Backup policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup policy name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Policy creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Policy update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this policy should backup a single /// resource. @@ -36,19 +42,63 @@ pub struct BackupPolicy { pub resource_type: Option, /// How many days to keep the backup before it will be automatically deleted. #[serde(rename = "retention")] + #[serde(default = "default_retention")] pub retention: i64, /// Policy backup schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Is this policy enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_retention() -> i64 { + 1 +} + +fn default_schedule() -> String { + "0 * * * *".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_enabled() -> bool { + false +} + impl BackupPolicy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/backup_policy_list.rs b/src/models/backup_policy_list.rs index 299f36b..60a4ad3 100644 --- a/src/models/backup_policy_list.rs +++ b/src/models/backup_policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicyList { /// Total number of policies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupPolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_restoration.rs b/src/models/backup_restoration.rs index 45931ed..2dc302b 100644 --- a/src/models/backup_restoration.rs +++ b/src/models/backup_restoration.rs @@ -8,38 +8,89 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Restoration update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Backup archive ID. #[serde(rename = "archiveId")] + #[serde(default = "default_archive_id")] pub archive_id: String, /// Backup policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// The status of the restoration. Possible values: pending, downloading, /// processing, completed, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The restoration start time. Null until the restoration starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, - /// Optional data in key-value object. + /// Restoration options as a key-value object. #[serde(rename = "options")] - pub options: String, + #[serde(default = "default_options")] + pub options: serde_json::Value, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_archive_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_options() -> serde_json::Value { + serde_json::json!({}) } impl BackupRestoration { @@ -73,9 +124,15 @@ impl BackupRestoration { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -94,7 +151,7 @@ impl BackupRestoration { } /// Get options - pub fn options(&self) -> &String { + pub fn options(&self) -> &serde_json::Value { &self.options } } @@ -112,7 +169,6 @@ mod tests { let _ = _model.archive_id(); let _ = _model.policy_id(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_restoration_list.rs b/src/models/backup_restoration_list.rs index 65c9ad3..33d4196 100644 --- a/src/models/backup_restoration_list.rs +++ b/src/models/backup_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/billing_plan.rs b/src/models/billing_plan.rs index 936f3d8..1e43f95 100644 --- a/src/models/billing_plan.rs +++ b/src/models/billing_plan.rs @@ -8,33 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlan { /// Plan ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Plan name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Plan description #[serde(rename = "desc")] + #[serde(default = "default_desc")] pub desc: String, /// Plan order #[serde(rename = "order")] + #[serde(default = "default_order")] pub order: i64, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Trial days #[serde(rename = "trial")] + #[serde(default = "default_trial")] pub trial: i64, /// Bandwidth #[serde(rename = "bandwidth")] + #[serde(default = "default_bandwidth")] pub bandwidth: i64, /// Storage #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Image Transformations #[serde(rename = "imageTransformations")] + #[serde(default = "default_image_transformations")] pub image_transformations: i64, /// Screenshots generated #[serde(rename = "screenshotsGenerated")] + #[serde(default = "default_screenshots_generated")] pub screenshots_generated: i64, /// Members #[serde(rename = "members")] @@ -42,77 +52,100 @@ pub struct BillingPlan { pub members: Option, /// Webhooks #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: i64, /// Maximum WAF rules per project #[serde(rename = "wafRules")] + #[serde(default = "default_waf_rules")] pub waf_rules: i64, /// Maximum environments per project. 0 when the plan does not offer /// environments. #[serde(rename = "environments")] - #[serde(skip_serializing_if = "Option::is_none")] - pub environments: Option, + #[serde(default = "default_environments")] + pub environments: i64, /// Projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: i64, /// Platforms #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: i64, /// Users #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: i64, /// Teams #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: i64, /// Databases #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: i64, /// Database reads per month #[serde(rename = "databasesReads")] + #[serde(default = "default_databases_reads")] pub databases_reads: i64, /// Database writes per month #[serde(rename = "databasesWrites")] + #[serde(default = "default_databases_writes")] pub databases_writes: i64, /// Database batch size limit #[serde(rename = "databasesBatchSize")] + #[serde(default = "default_databases_batch_size")] pub databases_batch_size: i64, /// Buckets #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: i64, /// File size #[serde(rename = "fileSize")] + #[serde(default = "default_file_size")] pub file_size: i64, /// Functions #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: i64, /// Sites #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: i64, /// Function executions #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: i64, /// Rolling max executions retained per function/site #[serde(rename = "executionsRetentionCount")] + #[serde(default = "default_executions_retention_count")] pub executions_retention_count: i64, /// GB hours for functions #[serde(rename = "GBHours")] + #[serde(default = "default_gb_hours")] pub gb_hours: i64, /// Realtime connections #[serde(rename = "realtime")] + #[serde(default = "default_realtime")] pub realtime: i64, /// Realtime messages #[serde(rename = "realtimeMessages")] + #[serde(default = "default_realtime_messages")] pub realtime_messages: i64, /// Messages per month #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: i64, /// Topics for messaging #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: i64, /// SMS authentications per month #[serde(rename = "authPhone")] + #[serde(default = "default_auth_phone")] pub auth_phone: i64, /// Custom domains #[serde(rename = "domains")] + #[serde(default = "default_domains")] pub domains: i64, /// Activity log days #[serde(rename = "activityLogs")] @@ -120,6 +153,7 @@ pub struct BillingPlan { pub activity_logs: Option, /// Usage history days #[serde(rename = "usageLogs")] + #[serde(default = "default_usage_logs")] pub usage_logs: i64, /// Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). #[serde(rename = "usageLogsIntervals")] @@ -134,30 +168,38 @@ pub struct BillingPlan { /// Number of days of console inactivity before a project is paused. 0 means /// pausing is disabled. #[serde(rename = "projectInactivityDays")] + #[serde(default = "default_project_inactivity_days")] pub project_inactivity_days: i64, /// Alert threshold percentage #[serde(rename = "alertLimit")] + #[serde(default = "default_alert_limit")] pub alert_limit: i64, - /// Additional resources + /// Additional resources. Null when the plan does not support usage billing. #[serde(rename = "usage")] - pub usage: crate::models::UsageBillingPlan, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage: Option, /// Addons #[serde(rename = "addons")] pub addons: crate::models::BillingPlanAddon, /// Budget cap enabled or disabled. #[serde(rename = "budgetCapEnabled")] + #[serde(default = "default_budget_cap_enabled")] pub budget_cap_enabled: bool, /// Custom SMTP #[serde(rename = "customSmtp")] + #[serde(default = "default_custom_smtp")] pub custom_smtp: bool, /// Appwrite branding in email #[serde(rename = "emailBranding")] + #[serde(default = "default_email_branding")] pub email_branding: bool, /// Does plan require payment method #[serde(rename = "requiresPaymentMethod")] + #[serde(default = "default_requires_payment_method")] pub requires_payment_method: bool, /// Does plan require billing address #[serde(rename = "requiresBillingAddress")] + #[serde(default = "default_requires_billing_address")] pub requires_billing_address: bool, /// ISO country codes eligible for this regional plan. Empty means no /// restriction. @@ -166,42 +208,55 @@ pub struct BillingPlan { pub eligible_countries: Option>, /// Is the billing plan available #[serde(rename = "isAvailable")] + #[serde(default = "default_is_available")] pub is_available: bool, /// Can user change the plan themselves #[serde(rename = "selfService")] + #[serde(default = "default_self_service")] pub self_service: bool, /// Does plan enable premium support #[serde(rename = "premiumSupport")] + #[serde(default = "default_premium_support")] pub premium_support: bool, /// Does plan support budget cap #[serde(rename = "budgeting")] + #[serde(default = "default_budgeting")] pub budgeting: bool, /// Does plan support mock numbers #[serde(rename = "supportsMockNumbers")] + #[serde(default = "default_supports_mock_numbers")] pub supports_mock_numbers: bool, /// Does plan support organization roles #[serde(rename = "supportsOrganizationRoles")] + #[serde(default = "default_supports_organization_roles")] pub supports_organization_roles: bool, /// Does plan support credit #[serde(rename = "supportsCredits")] + #[serde(default = "default_supports_credits")] pub supports_credits: bool, /// Does plan support dedicated databases. #[serde(rename = "supportsDedicatedDatabases")] + #[serde(default = "default_supports_dedicated_databases")] pub supports_dedicated_databases: bool, /// Does plan support blocking disposable email addresses. #[serde(rename = "supportsDisposableEmailValidation")] + #[serde(default = "default_supports_disposable_email_validation")] pub supports_disposable_email_validation: bool, /// Does plan support requiring canonical email addresses. #[serde(rename = "supportsCanonicalEmailValidation")] + #[serde(default = "default_supports_canonical_email_validation")] pub supports_canonical_email_validation: bool, /// Does plan support blocking free email addresses. #[serde(rename = "supportsFreeEmailValidation")] + #[serde(default = "default_supports_free_email_validation")] pub supports_free_email_validation: bool, /// Does plan support restricting sign-ups to corporate email addresses only. #[serde(rename = "supportsCorporateEmailValidation")] + #[serde(default = "default_supports_corporate_email_validation")] pub supports_corporate_email_validation: bool, /// Does plan support project-specific member roles. #[serde(rename = "supportsProjectSpecificRoles")] + #[serde(default = "default_supports_project_specific_roles")] pub supports_project_specific_roles: bool, /// Does plan support backup policies. #[serde(rename = "backupsEnabled")] @@ -209,6 +264,7 @@ pub struct BillingPlan { pub backups_enabled: Option, /// Whether usage addons are calculated per project. #[serde(rename = "usagePerProject")] + #[serde(default = "default_usage_per_project")] pub usage_per_project: bool, /// Supported addons for this plan #[serde(rename = "supportedAddons")] @@ -219,16 +275,20 @@ pub struct BillingPlan { pub backup_policies: Option, /// Maximum function and site deployment size in MB #[serde(rename = "deploymentSize")] + #[serde(default = "default_deployment_size")] pub deployment_size: i64, /// Maximum function and site deployment size in MB #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// Shortest function schedule interval allowed, in minutes. 0 allows every /// interval. #[serde(rename = "functionsIntervalMinimum")] + #[serde(default = "default_functions_interval_minimum")] pub functions_interval_minimum: i64, /// Does the plan support encrypted string attributes or not. #[serde(rename = "databasesAllowEncrypt")] + #[serde(default = "default_databases_allow_encrypt")] pub databases_allow_encrypt: bool, /// Plan specific limits #[serde(rename = "limits")] @@ -244,6 +304,7 @@ pub struct BillingPlan { /// Included monthly dedicated-database compute credit in USD. Resets each /// billing cycle with no roll-over. #[serde(rename = "databaseComputeCredit")] + #[serde(default = "default_database_compute_credit")] pub database_compute_credit: f64, /// Dedicated database limits available to this plan. #[serde(rename = "dedicatedDatabases")] @@ -251,6 +312,250 @@ pub struct BillingPlan { pub dedicated_databases: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_desc() -> String { + "".to_string() +} + +fn default_order() -> i64 { + 0 +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_trial() -> i64 { + 0 +} + +fn default_bandwidth() -> i64 { + 0 +} + +fn default_storage() -> i64 { + 0 +} + +fn default_image_transformations() -> i64 { + 0 +} + +fn default_screenshots_generated() -> i64 { + 0 +} + +fn default_webhooks() -> i64 { + 0 +} + +fn default_waf_rules() -> i64 { + 0 +} + +fn default_environments() -> i64 { + 0 +} + +fn default_projects() -> i64 { + 0 +} + +fn default_platforms() -> i64 { + 0 +} + +fn default_users() -> i64 { + 0 +} + +fn default_teams() -> i64 { + 0 +} + +fn default_databases() -> i64 { + 0 +} + +fn default_databases_reads() -> i64 { + 0 +} + +fn default_databases_writes() -> i64 { + 0 +} + +fn default_databases_batch_size() -> i64 { + 0 +} + +fn default_buckets() -> i64 { + 0 +} + +fn default_file_size() -> i64 { + 0 +} + +fn default_functions() -> i64 { + 0 +} + +fn default_sites() -> i64 { + 0 +} + +fn default_executions() -> i64 { + 0 +} + +fn default_executions_retention_count() -> i64 { + 1000 +} + +fn default_gb_hours() -> i64 { + 0 +} + +fn default_realtime() -> i64 { + 0 +} + +fn default_realtime_messages() -> i64 { + 0 +} + +fn default_messages() -> i64 { + 0 +} + +fn default_topics() -> i64 { + 0 +} + +fn default_auth_phone() -> i64 { + 0 +} + +fn default_domains() -> i64 { + 0 +} + +fn default_usage_logs() -> i64 { + 0 +} + +fn default_project_inactivity_days() -> i64 { + 0 +} + +fn default_alert_limit() -> i64 { + 80 +} + +fn default_budget_cap_enabled() -> bool { + false +} + +fn default_custom_smtp() -> bool { + false +} + +fn default_email_branding() -> bool { + false +} + +fn default_requires_payment_method() -> bool { + true +} + +fn default_requires_billing_address() -> bool { + false +} + +fn default_is_available() -> bool { + true +} + +fn default_self_service() -> bool { + true +} + +fn default_premium_support() -> bool { + true +} + +fn default_budgeting() -> bool { + true +} + +fn default_supports_mock_numbers() -> bool { + true +} + +fn default_supports_organization_roles() -> bool { + true +} + +fn default_supports_credits() -> bool { + false +} + +fn default_supports_dedicated_databases() -> bool { + false +} + +fn default_supports_disposable_email_validation() -> bool { + false +} + +fn default_supports_canonical_email_validation() -> bool { + false +} + +fn default_supports_free_email_validation() -> bool { + false +} + +fn default_supports_corporate_email_validation() -> bool { + false +} + +fn default_supports_project_specific_roles() -> bool { + false +} + +fn default_usage_per_project() -> bool { + true +} + +fn default_deployment_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_functions_interval_minimum() -> i64 { + 0 +} + +fn default_databases_allow_encrypt() -> bool { + false +} + +fn default_database_compute_credit() -> f64 { + 0.0 +} + impl BillingPlan { /// Get id pub fn id(&self) -> &String { @@ -323,15 +628,9 @@ impl BillingPlan { &self.waf_rules } - /// Set environments - pub fn set_environments(mut self, environments: i64) -> Self { - self.environments = Some(environments); - self - } - /// Get environments - pub fn environments(&self) -> Option<&i64> { - self.environments.as_ref() + pub fn environments(&self) -> &i64 { + &self.environments } /// Get projects @@ -490,9 +789,15 @@ impl BillingPlan { &self.alert_limit } + /// Set usage + pub fn set_usage(mut self, usage: crate::models::UsageBillingPlan) -> Self { + self.usage = Some(usage); + self + } + /// Get usage - pub fn usage(&self) -> &crate::models::UsageBillingPlan { - &self.usage + pub fn usage(&self) -> Option<&crate::models::UsageBillingPlan> { + self.usage.as_ref() } /// Get addons @@ -721,6 +1026,7 @@ mod tests { let _ = _model.screenshots_generated(); let _ = _model.webhooks(); let _ = _model.waf_rules(); + let _ = _model.environments(); let _ = _model.projects(); let _ = _model.platforms(); let _ = _model.users(); @@ -745,7 +1051,6 @@ mod tests { let _ = _model.usage_logs(); let _ = _model.project_inactivity_days(); let _ = _model.alert_limit(); - let _ = _model.usage(); let _ = _model.addons(); let _ = _model.budget_cap_enabled(); let _ = _model.custom_smtp(); diff --git a/src/models/billing_plan_addon_details.rs b/src/models/billing_plan_addon_details.rs index 00aa018..3557b0d 100644 --- a/src/models/billing_plan_addon_details.rs +++ b/src/models/billing_plan_addon_details.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanAddonDetails { /// Is the addon supported in the plan? #[serde(rename = "supported")] + #[serde(default = "default_supported")] pub supported: bool, /// Addon plan included value #[serde(rename = "planIncluded")] + #[serde(default = "default_plan_included")] pub plan_included: i64, /// Addon limit #[serde(rename = "limit")] + #[serde(default = "default_limit")] pub limit: i64, /// Addon type #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Price currency #[serde(rename = "currency")] @@ -24,15 +28,46 @@ pub struct BillingPlanAddonDetails { pub currency: Option, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_supported() -> bool { + false +} + +fn default_plan_included() -> i64 { + 0 +} + +fn default_limit() -> i64 { + 0 +} + +fn default_type() -> String { + "numeric".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl BillingPlanAddonDetails { /// Get supported pub fn supported(&self) -> &bool { diff --git a/src/models/billing_plan_supported_addons.rs b/src/models/billing_plan_supported_addons.rs index af95b2d..74f7ee1 100644 --- a/src/models/billing_plan_supported_addons.rs +++ b/src/models/billing_plan_supported_addons.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanSupportedAddons { /// Whether the plan supports BAA (Business Associate Agreement) addon #[serde(rename = "baa")] + #[serde(default = "default_baa")] pub baa: bool, /// Whether the plan supports Premium Geo DB addon (project-level) #[serde(rename = "premiumGeoDB")] + #[serde(default = "default_premium_geo_db")] pub premium_geo_db: bool, /// Whether the plan supports Premium Geo DB addon (organization-level) #[serde(rename = "premiumGeoDBOrg")] + #[serde(default = "default_premium_geo_db_org")] pub premium_geo_db_org: bool, } +fn default_baa() -> bool { + false +} + +fn default_premium_geo_db() -> bool { + false +} + +fn default_premium_geo_db_org() -> bool { + false +} + impl BillingPlanSupportedAddons { /// Get baa pub fn baa(&self) -> &bool { diff --git a/src/models/block.rs b/src/models/block.rs index 9bd4591..8af751d 100644 --- a/src/models/block.rs +++ b/src/models/block.rs @@ -8,40 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct Block { /// Block creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource type that is blocked #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource identifier that is blocked #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Block mode. full blocks reads and writes; readOnly blocks writes only. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, - /// Reason for the block. Can be null if no reason was provided. - #[serde(rename = "reason")] - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// Block expiration date in ISO 8601 format. Can be null if the block does not /// expire. #[serde(rename = "expiredAt")] #[serde(skip_serializing_if = "Option::is_none")] pub expired_at: Option, - /// Name of the project this block applies to. - #[serde(rename = "projectName")] - pub project_name: String, - /// Region of the project this block applies to. - #[serde(rename = "region")] - pub region: String, - /// Name of the organization that owns the project. - #[serde(rename = "organizationName")] - pub organization_name: String, - /// ID of the organization that owns the project. - #[serde(rename = "organizationId")] - pub organization_id: String, - /// Billing plan of the organization that owns the project. - #[serde(rename = "billingPlan")] - pub billing_plan: String, +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_mode() -> String { + "full".to_string() } impl Block { @@ -65,17 +66,6 @@ impl Block { &self.mode } - /// Set reason - pub fn set_reason(mut self, reason: String) -> Self { - self.reason = Some(reason); - self - } - - /// Get reason - pub fn reason(&self) -> Option<&String> { - self.reason.as_ref() - } - /// Set expired_at pub fn set_expired_at(mut self, expired_at: String) -> Self { self.expired_at = Some(expired_at); @@ -86,31 +76,6 @@ impl Block { pub fn expired_at(&self) -> Option<&String> { self.expired_at.as_ref() } - - /// Get project_name - pub fn project_name(&self) -> &String { - &self.project_name - } - - /// Get region - pub fn region(&self) -> &String { - &self.region - } - - /// Get organization_name - pub fn organization_name(&self) -> &String { - &self.organization_name - } - - /// Get organization_id - pub fn organization_id(&self) -> &String { - &self.organization_id - } - - /// Get billing_plan - pub fn billing_plan(&self) -> &String { - &self.billing_plan - } } #[cfg(test)] @@ -124,11 +89,6 @@ mod tests { let _ = _model.resource_type(); let _ = _model.resource_id(); let _ = _model.mode(); - let _ = _model.project_name(); - let _ = _model.region(); - let _ = _model.organization_name(); - let _ = _model.organization_id(); - let _ = _model.billing_plan(); } #[test] diff --git a/src/models/bucket.rs b/src/models/bucket.rs index 8140e6a..feffbb9 100644 --- a/src/models/bucket.rs +++ b/src/models/bucket.rs @@ -8,52 +8,122 @@ use serde::{Deserialize, Serialize}; pub struct Bucket { /// Bucket ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Bucket update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Bucket permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Whether file-level security is enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "fileSecurity")] + #[serde(default = "default_file_security")] pub file_security: bool, /// Bucket name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Bucket enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Maximum file size supported. #[serde(rename = "maximumFileSize")] + #[serde(default = "default_maximum_file_size")] pub maximum_file_size: i64, /// Allowed file extensions. #[serde(rename = "allowedFileExtensions")] + #[serde(default = "default_allowed_file_extensions")] pub allowed_file_extensions: Vec, /// Compression algorithm chosen for compression. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, /// Bucket is encrypted. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Virus scanning is enabled. #[serde(rename = "antivirus")] + #[serde(default = "default_antivirus")] pub antivirus: bool, /// Image transformations are enabled. #[serde(rename = "transformations")] + #[serde(default = "default_transformations")] pub transformations: bool, /// Total size of this bucket in bytes. #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_file_security() -> bool { + false +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_maximum_file_size() -> i64 { + 0 +} + +fn default_allowed_file_extensions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_compression() -> String { + "".to_string() +} + +fn default_encryption() -> bool { + true +} + +fn default_antivirus() -> bool { + true +} + +fn default_transformations() -> bool { + true +} + +fn default_total_size() -> i64 { + 0 +} + impl Bucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/bucket_list.rs b/src/models/bucket_list.rs index 0f76efc..a29bb00 100644 --- a/src/models/bucket_list.rs +++ b/src/models/bucket_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BucketList { /// Total number of buckets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of buckets. #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_buckets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BucketList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/collection.rs b/src/models/collection.rs index 715c303..fd9bc8a 100644 --- a/src/models/collection.rs +++ b/src/models/collection.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Collection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Collection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/collection_list.rs b/src/models/collection_list.rs index 97983c6..c9f7bfe 100644 --- a/src/models/collection_list.rs +++ b/src/models/collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_bigint.rs b/src/models/column_bigint.rs index 1228086..9dd23d7 100644 --- a/src/models/column_bigint.rs +++ b/src/models/column_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBigint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBigint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBigint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_boolean.rs b/src/models/column_boolean.rs index 65aa9af..d2f4fe9 100644 --- a/src/models/column_boolean.rs +++ b/src/models/column_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBoolean { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBoolean { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_datetime.rs b/src/models/column_datetime.rs index a172665..13c23ca 100644 --- a/src/models/column_datetime.rs +++ b/src/models/column_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnDatetime { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnDatetime { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct ColumnDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_email.rs b/src/models/column_email.rs index f1c1037..5fc9bb6 100644 --- a/src/models/column_email.rs +++ b/src/models/column_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEmail { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEmail { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnEmail { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl ColumnEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_enum.rs b/src/models/column_enum.rs index d9b6b4f..bf66e79 100644 --- a/src/models/column_enum.rs +++ b/src/models/column_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEnum { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEnum { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct ColumnEnum { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -46,6 +54,38 @@ pub struct ColumnEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl ColumnEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_float.rs b/src/models/column_float.rs index 865bd38..55326bc 100644 --- a/src/models/column_float.rs +++ b/src/models/column_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnFloat { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnFloat { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnFloat { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_index.rs b/src/models/column_index.rs index 7e2a97b..ec406a7 100644 --- a/src/models/column_index.rs +++ b/src/models/column_index.rs @@ -8,32 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndex { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Index columns length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +50,42 @@ pub struct ColumnIndex { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/column_index_list.rs b/src/models/column_index_list.rs index 2ea7645..748a2c5 100644 --- a/src/models/column_index_list.rs +++ b/src/models/column_index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_integer.rs b/src/models/column_integer.rs index 8a6cd9e..39fb5f6 100644 --- a/src/models/column_integer.rs +++ b/src/models/column_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnInteger { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnInteger { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnInteger { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_ip.rs b/src/models/column_ip.rs index a94cf00..9aa5287 100644 --- a/src/models/column_ip.rs +++ b/src/models/column_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIp { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnIp { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnIp { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl ColumnIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_line.rs b/src/models/column_line.rs index 01d2239..6befae7 100644 --- a/src/models/column_line.rs +++ b/src/models/column_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLine { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLine { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLine { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_list.rs b/src/models/column_list.rs index aaa362b..55fc758 100644 --- a/src/models/column_list.rs +++ b/src/models/column_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnList { /// Total number of columns in the given table. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_longtext.rs b/src/models/column_longtext.rs index 6d418d9..222e746 100644 --- a/src/models/column_longtext.rs +++ b/src/models/column_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLongtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLongtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_mediumtext.rs b/src/models/column_mediumtext.rs index 90b3d33..f1c032b 100644 --- a/src/models/column_mediumtext.rs +++ b/src/models/column_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnMediumtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnMediumtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_point.rs b/src/models/column_point.rs index 6d402ea..4b08010 100644 --- a/src/models/column_point.rs +++ b/src/models/column_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPoint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPoint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPoint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_polygon.rs b/src/models/column_polygon.rs index d0afe7e..5ff50f0 100644 --- a/src/models/column_polygon.rs +++ b/src/models/column_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPolygon { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPolygon { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPolygon { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_relationship.rs b/src/models/column_relationship.rs index 441476a..92304e7 100644 --- a/src/models/column_relationship.rs +++ b/src/models/column_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnRelationship { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct ColumnRelationship { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related table. #[serde(rename = "relatedTable")] pub related_table: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl ColumnRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_string.rs b/src/models/column_string.rs index c7128c3..8d8e515 100644 --- a/src/models/column_string.rs +++ b/src/models/column_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnString { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnString { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnString { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_text.rs b/src/models/column_text.rs index 0ad76c5..e1b305c 100644 --- a/src/models/column_text.rs +++ b/src/models/column_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnText { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnText { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnText { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_url.rs b/src/models/column_url.rs index b509d2f..4fce4a3 100644 --- a/src/models/column_url.rs +++ b/src/models/column_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnUrl { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnUrl { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnUrl { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl ColumnUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_varchar.rs b/src/models/column_varchar.rs index e163c87..53e8c58 100644 --- a/src/models/column_varchar.rs +++ b/src/models/column_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnVarchar { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnVarchar { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/continent.rs b/src/models/continent.rs index c13199c..34286cd 100644 --- a/src/models/continent.rs +++ b/src/models/continent.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Continent { /// Continent name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Continent two letter code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Continent { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/continent_list.rs b/src/models/continent_list.rs index 2490dbd..677e579 100644 --- a/src/models/continent_list.rs +++ b/src/models/continent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ContinentList { /// Total number of continents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of continents. #[serde(rename = "continents")] + #[serde(default = "default_continents")] pub continents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_continents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ContinentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/country.rs b/src/models/country.rs index bf48f60..2c9db22 100644 --- a/src/models/country.rs +++ b/src/models/country.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Country { /// Country name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Country { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/country_list.rs b/src/models/country_list.rs index bf4eeb1..b004cb8 100644 --- a/src/models/country_list.rs +++ b/src/models/country_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CountryList { /// Total number of countries that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of countries. #[serde(rename = "countries")] + #[serde(default = "default_countries")] pub countries: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_countries() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CountryList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/currency.rs b/src/models/currency.rs index 9d45fe6..c5d5091 100644 --- a/src/models/currency.rs +++ b/src/models/currency.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct Currency { /// Currency symbol. #[serde(rename = "symbol")] + #[serde(default = "default_symbol")] pub symbol: String, /// Currency name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Currency native symbol. #[serde(rename = "symbolNative")] + #[serde(default = "default_symbol_native")] pub symbol_native: String, /// Number of decimal digits. #[serde(rename = "decimalDigits")] + #[serde(default = "default_decimal_digits")] pub decimal_digits: i64, /// Currency digit rounding. #[serde(rename = "rounding")] + #[serde(default = "default_rounding")] pub rounding: f64, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Currency plural name #[serde(rename = "namePlural")] + #[serde(default = "default_name_plural")] pub name_plural: String, } +fn default_symbol() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_symbol_native() -> String { + "".to_string() +} + +fn default_decimal_digits() -> i64 { + 0 +} + +fn default_rounding() -> f64 { + 0.0 +} + +fn default_code() -> String { + "".to_string() +} + +fn default_name_plural() -> String { + "".to_string() +} + impl Currency { /// Get symbol pub fn symbol(&self) -> &String { diff --git a/src/models/currency_list.rs b/src/models/currency_list.rs index 86fa828..001a779 100644 --- a/src/models/currency_list.rs +++ b/src/models/currency_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CurrencyList { /// Total number of currencies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of currencies. #[serde(rename = "currencies")] + #[serde(default = "default_currencies")] pub currencies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_currencies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CurrencyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database.rs b/src/models/database.rs index 5c0a45d..b582d01 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -8,23 +8,29 @@ use serde::{Deserialize, Serialize}; pub struct Database { /// Database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Database creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the /// database is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Database type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: crate::enums::DatabaseType, /// Dedicated database lifecycle status. Null when the database has no valid /// dedicated backing. @@ -53,8 +59,9 @@ pub struct Database { #[serde(rename = "error")] #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, - /// Container status of the dedicated backing: active or inactive. Null when - /// the database has no dedicated backing or the runtime has not reported one. + /// Container status of the dedicated backing: active, inactive, or failed (a + /// wake was declined because the backing namespace is gone). Null when the + /// database has no dedicated backing or the runtime has not reported one. #[serde(rename = "containerStatus")] #[serde(skip_serializing_if = "Option::is_none")] pub container_status: Option, @@ -74,6 +81,30 @@ pub struct Database { pub archives: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> crate::enums::DatabaseType { + serde_json::from_value(serde_json::json!("legacy")).unwrap() +} + impl Database { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_list.rs b/src/models/database_list.rs index 78fe039..919f60b 100644 --- a/src/models/database_list.rs +++ b/src/models/database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_migration.rs b/src/models/database_migration.rs index 0a05aa6..e2ca204 100644 --- a/src/models/database_migration.rs +++ b/src/models/database_migration.rs @@ -8,63 +8,148 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigration { /// Database migration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Migration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Migration update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns the migrating database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Logical database ID being migrated. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Dedicated compute specification provisioned for the migration target. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Migration phase. Possible values: pending, provisioned, capturing, /// backfilling, catching_up, verifying, ready_to_cutover, cutover, soaking, /// done, failed, rolled_back. #[serde(rename = "phase")] + #[serde(default = "default_phase")] pub phase: String, /// Number of times a migration step has failed and been recorded. #[serde(rename = "attempt")] + #[serde(default = "default_attempt")] pub attempt: i64, /// Reason the most recent migration step failed, empty while none has. #[serde(rename = "lastError")] + #[serde(default = "default_last_error")] pub last_error: String, /// Number of documents still pending replication to the target. #[serde(rename = "lagDocuments")] + #[serde(default = "default_lag_documents")] pub lag_documents: i64, /// Highest source changelog sequence applied to the target so far. #[serde(rename = "changelogWatermark")] + #[serde(default = "default_changelog_watermark")] pub changelog_watermark: i64, /// Time the migrated data was verified against the source in ISO 8601 format. #[serde(rename = "verifiedAt")] + #[serde(default = "default_verified_at")] pub verified_at: String, /// Time routing was flipped to the target in ISO 8601 format. #[serde(rename = "cutoverAt")] + #[serde(default = "default_cutover_at")] pub cutover_at: String, /// Time the post-cutover soak window ends in ISO 8601 format. #[serde(rename = "soakUntil")] + #[serde(default = "default_soak_until")] pub soak_until: String, /// Whether the migration cuts over automatically once ready. Set when the /// migration is created and never changed afterwards, so it always reports /// what was asked for. #[serde(rename = "autoCutover")] + #[serde(default = "default_auto_cutover")] pub auto_cutover: bool, /// Whether a cutover has been requested and not yet attempted. Set by the /// cutover endpoint and cleared when the attempt is made, so a cutover that /// fails a check parks the migration again rather than retrying on its own. #[serde(rename = "cutoverRequested")] + #[serde(default = "default_cutover_requested")] pub cutover_requested: bool, /// Whether the migration is paused. #[serde(rename = "paused")] + #[serde(default = "default_paused")] pub paused: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_phase() -> String { + "pending".to_string() +} + +fn default_attempt() -> i64 { + 0 +} + +fn default_last_error() -> String { + "".to_string() +} + +fn default_lag_documents() -> i64 { + 0 +} + +fn default_changelog_watermark() -> i64 { + 0 +} + +fn default_verified_at() -> String { + "".to_string() +} + +fn default_cutover_at() -> String { + "".to_string() +} + +fn default_soak_until() -> String { + "".to_string() +} + +fn default_auto_cutover() -> bool { + true +} + +fn default_cutover_requested() -> bool { + false +} + +fn default_paused() -> bool { + false +} + impl DatabaseMigration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_migration_list.rs b/src/models/database_migration_list.rs index ad8e45f..1029847 100644 --- a/src/models/database_migration_list.rs +++ b/src/models/database_migration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigrationList { /// Total number of migrations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of migrations. #[serde(rename = "migrations")] + #[serde(default = "default_migrations")] pub migrations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_migrations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseMigrationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_status.rs b/src/models/database_status.rs index d0b0403..0796051 100644 --- a/src/models/database_status.rs +++ b/src/models/database_status.rs @@ -9,25 +9,32 @@ pub struct DatabaseStatus { /// Overall health status: healthy, degraded, unhealthy, or unknown when /// nothing could be measured. #[serde(rename = "health")] + #[serde(default = "default_health")] pub health: String, /// Whether the database is ready to accept connections. #[serde(rename = "ready")] + #[serde(default = "default_ready")] pub ready: bool, /// Database engine: postgresql, mysql, or mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Database uptime in seconds. #[serde(rename = "uptime")] + #[serde(default = "default_uptime")] pub uptime: i64, - /// Connection statistics. + /// Connection statistics. Null when the database has not been probed. #[serde(rename = "connections")] - pub connections: crate::models::DatabaseStatusConnections, + #[serde(skip_serializing_if = "Option::is_none")] + pub connections: Option, /// Requested replication sync mode. Possible values: async, sync, quorum. /// Compare with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. @@ -36,13 +43,16 @@ pub struct DatabaseStatus { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -62,12 +72,58 @@ pub struct DatabaseStatus { /// appears, including one the backend has not brought up, which is reported as /// not healthy. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: Vec, /// Storage volume information. #[serde(rename = "volumes")] + #[serde(default = "default_volumes")] pub volumes: Vec, } +fn default_health() -> String { + "unknown".to_string() +} + +fn default_ready() -> bool { + false +} + +fn default_engine() -> String { + "postgresql".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_uptime() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_replicas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_volumes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseStatus { /// Get health pub fn health(&self) -> &String { @@ -94,9 +150,18 @@ impl DatabaseStatus { &self.uptime } + /// Set connections + pub fn set_connections( + mut self, + connections: crate::models::DatabaseStatusConnections, + ) -> Self { + self.connections = Some(connections); + self + } + /// Get connections - pub fn connections(&self) -> &crate::models::DatabaseStatusConnections { - &self.connections + pub fn connections(&self) -> Option<&crate::models::DatabaseStatusConnections> { + self.connections.as_ref() } /// Get sync_mode @@ -164,7 +229,6 @@ mod tests { let _ = _model.engine(); let _ = _model.version(); let _ = _model.uptime(); - let _ = _model.connections(); let _ = _model.sync_mode(); let _ = _model.sync_degraded(); let _ = _model.sync_acknowledgements(); diff --git a/src/models/database_status_connections.rs b/src/models/database_status_connections.rs index 0e7652d..8d7110a 100644 --- a/src/models/database_status_connections.rs +++ b/src/models/database_status_connections.rs @@ -8,14 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusConnections { /// Current number of active connections. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: i64, /// The engine's own max_connections. On a pooled database this is the backend /// limit the pooler multiplexes onto, not the ceiling a client pool may reach /// — that is networkMaxConnections on the database resource. #[serde(rename = "max")] + #[serde(default = "default_max")] pub max: i64, } +fn default_current() -> i64 { + 0 +} + +fn default_max() -> i64 { + 100 +} + impl DatabaseStatusConnections { /// Get current pub fn current(&self) -> &i64 { diff --git a/src/models/database_status_replica.rs b/src/models/database_status_replica.rs index f182cdb..ad15e30 100644 --- a/src/models/database_status_replica.rs +++ b/src/models/database_status_replica.rs @@ -9,15 +9,18 @@ pub struct DatabaseStatusReplica { /// Member index within the database. Read `role` for which member accepts /// writes: a failover moves the primary without renumbering the indexes. #[serde(rename = "index")] + #[serde(default = "default_index")] pub index: i64, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology, so no member can be named /// the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Whether the replica is healthy. #[serde(rename = "healthy")] + #[serde(default = "default_healthy")] pub healthy: bool, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -35,6 +38,18 @@ pub struct DatabaseStatusReplica { pub lag_seconds: Option, } +fn default_index() -> i64 { + 0 +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_healthy() -> bool { + false +} + impl DatabaseStatusReplica { /// Get index pub fn index(&self) -> &i64 { diff --git a/src/models/database_status_volume.rs b/src/models/database_status_volume.rs index 35ea096..0d21f7a 100644 --- a/src/models/database_status_volume.rs +++ b/src/models/database_status_volume.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusVolume { /// Mount path of the volume. #[serde(rename = "path")] + #[serde(default = "default_path")] pub path: String, /// Percentage of storage used. #[serde(rename = "usedPercent")] + #[serde(default = "default_used_percent")] pub used_percent: String, /// Available storage space. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: String, /// Whether the volume is mounted. #[serde(rename = "mounted")] + #[serde(default = "default_mounted")] pub mounted: bool, } +fn default_path() -> String { + "".to_string() +} + +fn default_used_percent() -> String { + "0%".to_string() +} + +fn default_available() -> String { + "0GB".to_string() +} + +fn default_mounted() -> bool { + false +} + impl DatabaseStatusVolume { /// Get path pub fn path(&self) -> &String { diff --git a/src/models/dedicated_database.rs b/src/models/dedicated_database.rs index 33e9d5c..07cf2c4 100644 --- a/src/models/dedicated_database.rs +++ b/src/models/dedicated_database.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabase { /// Dedicated database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns this database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Database display name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Product API that owns this database: tablesdb, documentsdb, vectorsdb, /// mysql, postgresql, or mongodb. #[serde(rename = "api")] - pub api: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub api: Option, /// Database engine: postgresql, mysql, or mongodb. Null until the backing /// reports one. #[serde(rename = "engine")] - pub engine: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub engine: Option, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Specification identifier. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Database backend provider. Possible values: edge. #[serde(rename = "backend")] + #[serde(default = "default_backend")] pub backend: String, /// Database hostname for connections. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Database port for connections. Derived from the engine when the backing has /// not reported one yet. #[serde(rename = "connectionPort")] - pub connection_port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub connection_port: Option, /// Database username for connections. #[serde(rename = "connectionUser")] + #[serde(default = "default_connection_user")] pub connection_user: String, /// Database password for connections. #[serde(rename = "connectionPassword")] + #[serde(default = "default_connection_password")] pub connection_password: String, /// Committed generation of the primary connection credentials. Null until the /// rotation contract has been initialized. #[serde(rename = "credentialGeneration")] - pub credential_generation: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub credential_generation: Option, /// Full database connection string (URI format). #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, /// Whether SSL/TLS is required for client connections. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database status. Possible values: provisioning, ready, inactive, paused, /// failed, deleted, restoring, scaling. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// Container status for lifecycle-managed database runtimes: active or - /// inactive. + /// Container status for lifecycle-managed database runtimes: active, inactive, + /// or failed (a wake was declined because the backing namespace is gone). #[serde(rename = "containerStatus")] + #[serde(default = "default_container_status")] pub container_status: String, /// Last activity timestamp in ISO 8601 format. #[serde(rename = "lastAccessedAt")] @@ -82,29 +101,34 @@ pub struct DedicatedDatabase { /// Idle-lifecycle state of the database. Possible values: active, warm, cold, /// hibernated. #[serde(rename = "lifecycleState")] + #[serde(default = "default_lifecycle_state")] pub lifecycle_state: String, /// Minutes of inactivity before container scales to zero. #[serde(rename = "idleTimeoutMinutes")] + #[serde(default = "default_idle_timeout_minutes")] pub idle_timeout_minutes: i64, /// CPU allocated in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Memory allocated in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Storage allocated in GB. #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Storage resize status. Possible values: idle (no resize in flight), /// resizing (the volume is growing towards storageTargetGb). #[serde(rename = "storageStatus")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_status: Option, + #[serde(default = "default_storage_status")] + pub storage_status: String, /// Size in GB the volume is growing towards while storageStatus is resizing. 0 /// when no resize is in flight. #[serde(rename = "storageTargetGb")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_target_gb: Option, + #[serde(default = "default_storage_target_gb")] + pub storage_target_gb: i64, /// Time the in-flight storage resize started, in ISO 8601 format. #[serde(rename = "storageResizeStartedAt")] #[serde(skip_serializing_if = "Option::is_none")] @@ -112,86 +136,290 @@ pub struct DedicatedDatabase { /// Storage class. Currently always 'ssd'; DigitalOcean exposes a single /// block-storage class. #[serde(rename = "storageClass")] + #[serde(default = "default_storage_class")] pub storage_class: String, /// Maximum storage allowed in GB. 0 means use system default. #[serde(rename = "storageMaxGb")] + #[serde(default = "default_storage_max_gb")] pub storage_max_gb: i64, /// Kubernetes node pool where the database is scheduled. #[serde(rename = "nodePool")] + #[serde(default = "default_node_pool")] pub node_pool: String, /// Number of high availability replicas. High availability is enabled when /// greater than 0. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Replication sync mode: async, sync, or quorum. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Maximum concurrent client connections. This is the limit a client pool may /// reach; the engine's own max_connections reported by the status endpoint is /// a smaller backend limit the pooler multiplexes onto and does not constrain /// a client pool. #[serde(rename = "networkMaxConnections")] + #[serde(default = "default_network_max_connections")] pub network_max_connections: i64, /// Connection idle timeout in seconds. #[serde(rename = "networkIdleTimeoutSeconds")] + #[serde(default = "default_network_idle_timeout_seconds")] pub network_idle_timeout_seconds: i64, /// IP addresses/CIDR ranges allowed to connect. #[serde(rename = "networkIPAllowlist")] + #[serde(default = "default_network_ip_allowlist")] pub network_ip_allowlist: Vec, /// Whether automatic backups are enabled. #[serde(rename = "backupEnabled")] + #[serde(default = "default_backup_enabled")] pub backup_enabled: bool, /// Whether point-in-time recovery is enabled. #[serde(rename = "pitr")] + #[serde(default = "default_pitr")] pub pitr: bool, /// Number of days to retain PITR data. #[serde(rename = "pitrRetentionDays")] + #[serde(default = "default_pitr_retention_days")] pub pitr_retention_days: i64, /// Whether automatic storage expansion is enabled. #[serde(rename = "storageAutoscaling")] + #[serde(default = "default_storage_autoscaling")] pub storage_autoscaling: bool, /// Storage usage percentage that triggers automatic expansion. #[serde(rename = "storageAutoscalingThresholdPercent")] + #[serde(default = "default_storage_autoscaling_threshold_percent")] pub storage_autoscaling_threshold_percent: i64, - /// Maximum storage size in GB for autoscaling. 0 means no limit. + /// Maximum storage size in GB for autoscaling. Defaults to 3 times the + /// specification's storage. 0 means no limit. #[serde(rename = "storageAutoscalingMaxGb")] + #[serde(default = "default_storage_autoscaling_max_gb")] pub storage_autoscaling_max_gb: i64, /// Day of the week for the maintenance window. Possible values: sun, mon, tue, /// wed, thu, fri, sat. #[serde(rename = "maintenanceWindowDay")] + #[serde(default = "default_maintenance_window_day")] pub maintenance_window_day: String, /// Hour in UTC (0-23) when the maintenance window starts. #[serde(rename = "maintenanceWindowHourUtc")] + #[serde(default = "default_maintenance_window_hour_utc")] pub maintenance_window_hour_utc: i64, /// Whether metrics collection is enabled. #[serde(rename = "metricsEnabled")] + #[serde(default = "default_metrics_enabled")] pub metrics_enabled: bool, /// Whether the SQL API sidecar is enabled for this database. #[serde(rename = "sqlApiEnabled")] + #[serde(default = "default_sql_api_enabled")] pub sql_api_enabled: bool, /// Statement types accepted by the SQL API. Defaults to read/write DML only; /// DDL/DCL types (CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE) are opt-in per /// database. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, /// DROP, TRUNCATE, GRANT, REVOKE. #[serde(rename = "sqlApiAllowedStatements")] + #[serde(default = "default_sql_api_allowed_statements")] pub sql_api_allowed_statements: Vec, /// Maximum rows returned per SQL API execution. Results larger than this are /// truncated. #[serde(rename = "sqlApiMaxRows")] + #[serde(default = "default_sql_api_max_rows")] pub sql_api_max_rows: i64, /// Maximum serialised SQL API result payload in bytes. Results larger than /// this are truncated. #[serde(rename = "sqlApiMaxBytes")] + #[serde(default = "default_sql_api_max_bytes")] pub sql_api_max_bytes: i64, /// Maximum server-side SQL API execution time in seconds before the query is /// cancelled. #[serde(rename = "sqlApiTimeoutSeconds")] + #[serde(default = "default_sql_api_timeout_seconds")] pub sql_api_timeout_seconds: i64, /// Error message if status is failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_backend() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_connection_user() -> String { + "".to_string() +} + +fn default_connection_password() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_status() -> String { + "provisioning".to_string() +} + +fn default_container_status() -> String { + "".to_string() +} + +fn default_lifecycle_state() -> String { + "".to_string() +} + +fn default_idle_timeout_minutes() -> i64 { + 15 +} + +fn default_cpu() -> i64 { + 500 +} + +fn default_memory() -> i64 { + 512 +} + +fn default_storage() -> i64 { + 10 +} + +fn default_storage_status() -> String { + "idle".to_string() +} + +fn default_storage_target_gb() -> i64 { + 0 +} + +fn default_storage_class() -> String { + "ssd".to_string() +} + +fn default_storage_max_gb() -> i64 { + 0 +} + +fn default_node_pool() -> String { + "".to_string() +} + +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "".to_string() +} + +fn default_network_max_connections() -> i64 { + 100 +} + +fn default_network_idle_timeout_seconds() -> i64 { + 900 +} + +fn default_network_ip_allowlist() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_backup_enabled() -> bool { + true +} + +fn default_pitr() -> bool { + true +} + +fn default_pitr_retention_days() -> i64 { + 7 +} + +fn default_storage_autoscaling() -> bool { + true +} + +fn default_storage_autoscaling_threshold_percent() -> i64 { + 85 +} + +fn default_storage_autoscaling_max_gb() -> i64 { + 0 +} + +fn default_maintenance_window_day() -> String { + "sun".to_string() +} + +fn default_maintenance_window_hour_utc() -> i64 { + 3 +} + +fn default_metrics_enabled() -> bool { + false +} + +fn default_sql_api_enabled() -> bool { + true +} + +fn default_sql_api_allowed_statements() -> Vec { + serde_json::from_value(serde_json::json!(["SELECT", "INSERT", "UPDATE", "DELETE"])).unwrap() +} + +fn default_sql_api_max_rows() -> i64 { + 10000 +} + +fn default_sql_api_max_bytes() -> i64 { + 10485760 +} + +fn default_sql_api_timeout_seconds() -> i64 { + 30 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabase { /// Get id pub fn id(&self) -> &String { @@ -218,14 +446,26 @@ impl DedicatedDatabase { &self.name } + /// Set api + pub fn set_api(mut self, api: String) -> Self { + self.api = Some(api); + self + } + /// Get api - pub fn api(&self) -> &String { - &self.api + pub fn api(&self) -> Option<&String> { + self.api.as_ref() + } + + /// Set engine + pub fn set_engine(mut self, engine: String) -> Self { + self.engine = Some(engine); + self } /// Get engine - pub fn engine(&self) -> &String { - &self.engine + pub fn engine(&self) -> Option<&String> { + self.engine.as_ref() } /// Get version @@ -248,9 +488,15 @@ impl DedicatedDatabase { &self.hostname } + /// Set connection_port + pub fn set_connection_port(mut self, connection_port: i64) -> Self { + self.connection_port = Some(connection_port); + self + } + /// Get connection_port - pub fn connection_port(&self) -> &i64 { - &self.connection_port + pub fn connection_port(&self) -> Option<&i64> { + self.connection_port.as_ref() } /// Get connection_user @@ -263,9 +509,15 @@ impl DedicatedDatabase { &self.connection_password } + /// Set credential_generation + pub fn set_credential_generation(mut self, credential_generation: i64) -> Self { + self.credential_generation = Some(credential_generation); + self + } + /// Get credential_generation - pub fn credential_generation(&self) -> &i64 { - &self.credential_generation + pub fn credential_generation(&self) -> Option<&i64> { + self.credential_generation.as_ref() } /// Get connection_string @@ -335,26 +587,14 @@ impl DedicatedDatabase { &self.storage } - /// Set storage_status - pub fn set_storage_status(mut self, storage_status: String) -> Self { - self.storage_status = Some(storage_status); - self - } - /// Get storage_status - pub fn storage_status(&self) -> Option<&String> { - self.storage_status.as_ref() - } - - /// Set storage_target_gb - pub fn set_storage_target_gb(mut self, storage_target_gb: i64) -> Self { - self.storage_target_gb = Some(storage_target_gb); - self + pub fn storage_status(&self) -> &String { + &self.storage_status } /// Get storage_target_gb - pub fn storage_target_gb(&self) -> Option<&i64> { - self.storage_target_gb.as_ref() + pub fn storage_target_gb(&self) -> &i64 { + &self.storage_target_gb } /// Set storage_resize_started_at @@ -496,16 +736,12 @@ mod tests { let _ = _model.updated_at(); let _ = _model.project_id(); let _ = _model.name(); - let _ = _model.api(); - let _ = _model.engine(); let _ = _model.version(); let _ = _model.specification(); let _ = _model.backend(); let _ = _model.hostname(); - let _ = _model.connection_port(); let _ = _model.connection_user(); let _ = _model.connection_password(); - let _ = _model.credential_generation(); let _ = _model.connection_string(); let _ = _model.ssl(); let _ = _model.status(); @@ -515,6 +751,8 @@ mod tests { let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.storage(); + let _ = _model.storage_status(); + let _ = _model.storage_target_gb(); let _ = _model.storage_class(); let _ = _model.storage_max_gb(); let _ = _model.node_pool(); diff --git a/src/models/dedicated_database_backup.rs b/src/models/dedicated_database_backup.rs index 703d3d6..cef73b2 100644 --- a/src/models/dedicated_database_backup.rs +++ b/src/models/dedicated_database_backup.rs @@ -8,44 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackup { /// Backup ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID this backup belongs to. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup policy ID when the backup was created by a schedule. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// Backup trigger. Possible values: manual, schedule. #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup), wal (write-ahead log continuous /// archival). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Backup type that was requested. Differs from `type` when the backend could /// not run the requested type and took a different one instead, in which case /// `fallbackReason` explains why. Empty for backups taken before the requested /// type was recorded. #[serde(rename = "requestedType")] + #[serde(default = "default_requested_type")] pub requested_type: String, /// Why the backend ran a different backup type than the one requested. Empty /// when the backup ran as requested. #[serde(rename = "fallbackReason")] + #[serde(default = "default_fallback_reason")] pub fallback_reason: String, /// Backup status. Possible values: pending (queued for processing), running /// (currently in progress), completed (successfully finished), failed /// (encountered an error), verified (integrity check passed). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Backup size in bytes. #[serde(rename = "sizeBytes")] + #[serde(default = "default_size_bytes")] pub size_bytes: i64, /// Backup start time in ISO 8601 format. #[serde(rename = "startedAt")] @@ -73,9 +84,58 @@ pub struct DedicatedDatabaseBackup { pub log_position: Option, /// Error message if backup failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "manual".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_requested_type() -> String { + "".to_string() +} + +fn default_fallback_reason() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_size_bytes() -> i64 { + 0 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseBackup { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_backup_list.rs b/src/models/dedicated_database_backup_list.rs index 4833b14..7f173ad 100644 --- a/src/models/dedicated_database_backup_list.rs +++ b/src/models/dedicated_database_backup_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackupList { /// Total number of backups. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of backups. #[serde(rename = "backups")] + #[serde(default = "default_backups")] pub backups: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_backups() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBackupList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_backup_storage.rs b/src/models/dedicated_database_backup_storage.rs index 395e376..6756910 100644 --- a/src/models/dedicated_database_backup_storage.rs +++ b/src/models/dedicated_database_backup_storage.rs @@ -9,21 +9,46 @@ pub struct DedicatedDatabaseBackupStorage { /// Storage provider. Possible values: s3 (Amazon S3 or S3-compatible), gcs /// (Google Cloud Storage), azure (Azure Blob Storage). #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Storage bucket or container name. #[serde(rename = "bucket")] + #[serde(default = "default_bucket")] pub bucket: String, /// Storage region. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// Object key prefix for backups. #[serde(rename = "prefix")] + #[serde(default = "default_prefix")] pub prefix: String, /// Custom endpoint for S3-compatible storage. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_provider() -> String { + "".to_string() +} + +fn default_bucket() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_prefix() -> String { + "backups/".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl DedicatedDatabaseBackupStorage { /// Get provider pub fn provider(&self) -> &String { diff --git a/src/models/dedicated_database_branch.rs b/src/models/dedicated_database_branch.rs index db3bc19..6d283bf 100644 --- a/src/models/dedicated_database_branch.rs +++ b/src/models/dedicated_database_branch.rs @@ -8,43 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranch { /// Branch identifier. #[serde(rename = "branchId")] + #[serde(default = "default_branch_id")] pub branch_id: String, /// Branch name. #[serde(rename = "branchName")] + #[serde(default = "default_branch_name")] pub branch_name: String, /// Kubernetes namespace where the branch is deployed. #[serde(rename = "namespace")] + #[serde(default = "default_namespace")] pub namespace: String, /// Unix timestamp when the branch expires. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: i64, /// Branch hostname for direct connections. #[serde(rename = "host")] + #[serde(default = "default_host")] pub host: String, /// Branch port. Null until the backing reports one. #[serde(rename = "port")] - pub port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub port: Option, /// Advertised catalog the client connects to. MySQL/MariaDB use default; /// Postgres uses the routing label. #[serde(rename = "database")] + #[serde(default = "default_database")] pub database: String, /// Database username. Shared with the parent database. #[serde(rename = "username")] + #[serde(default = "default_username")] pub username: String, /// Database password. Shared with the parent database. #[serde(rename = "password")] + #[serde(default = "default_password")] pub password: String, /// Whether SSL is required. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database engine. Possible values: postgresql, mysql, mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Full connection string for the branch. #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, } +fn default_branch_id() -> String { + "".to_string() +} + +fn default_branch_name() -> String { + "".to_string() +} + +fn default_namespace() -> String { + "".to_string() +} + +fn default_expires_at() -> i64 { + 0 +} + +fn default_host() -> String { + "".to_string() +} + +fn default_database() -> String { + "".to_string() +} + +fn default_username() -> String { + "".to_string() +} + +fn default_password() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_engine() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + impl DedicatedDatabaseBranch { /// Get branch_id pub fn branch_id(&self) -> &String { @@ -71,9 +127,15 @@ impl DedicatedDatabaseBranch { &self.host } + /// Set port + pub fn set_port(mut self, port: i64) -> Self { + self.port = Some(port); + self + } + /// Get port - pub fn port(&self) -> &i64 { - &self.port + pub fn port(&self) -> Option<&i64> { + self.port.as_ref() } /// Get database @@ -119,7 +181,6 @@ mod tests { let _ = _model.namespace(); let _ = _model.expires_at(); let _ = _model.host(); - let _ = _model.port(); let _ = _model.database(); let _ = _model.username(); let _ = _model.password(); diff --git a/src/models/dedicated_database_branch_list.rs b/src/models/dedicated_database_branch_list.rs index 50da757..adb1575 100644 --- a/src/models/dedicated_database_branch_list.rs +++ b/src/models/dedicated_database_branch_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranchList { /// Total number of branches. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of branches. #[serde(rename = "branches")] + #[serde(default = "default_branches")] pub branches: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBranchList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_execution.rs b/src/models/dedicated_database_execution.rs index cbd430a..5998d80 100644 --- a/src/models/dedicated_database_execution.rs +++ b/src/models/dedicated_database_execution.rs @@ -9,26 +9,56 @@ pub struct DedicatedDatabaseExecution { /// Result rows as a list of column-name => value maps. Empty for non-returning /// statements. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, /// Number of rows returned (for SELECT) or affected (for /// INSERT/UPDATE/DELETE). #[serde(rename = "rowCount")] + #[serde(default = "default_row_count")] pub row_count: i64, /// Column metadata in result-set order. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Server-side execution time in milliseconds. #[serde(rename = "durationMs")] + #[serde(default = "default_duration_ms")] pub duration_ms: i64, /// True when the configured row or byte cap was hit and the result was /// truncated. #[serde(rename = "truncated")] + #[serde(default = "default_truncated")] pub truncated: bool, /// Serialised payload size in bytes. #[serde(rename = "bytes")] + #[serde(default = "default_bytes")] pub bytes: i64, } +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_row_count() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_duration_ms() -> i64 { + 0 +} + +fn default_truncated() -> bool { + false +} + +fn default_bytes() -> i64 { + 0 +} + impl DedicatedDatabaseExecution { /// Get rows pub fn rows(&self) -> &Vec { diff --git a/src/models/dedicated_database_execution_column.rs b/src/models/dedicated_database_execution_column.rs index 0ec270d..4ceffeb 100644 --- a/src/models/dedicated_database_execution_column.rs +++ b/src/models/dedicated_database_execution_column.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExecutionColumn { /// Column name as returned by the database. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Engine-specific column type (e.g. int4, text, timestamptz). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + impl DedicatedDatabaseExecutionColumn { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/dedicated_database_extensions.rs b/src/models/dedicated_database_extensions.rs index eefa389..a1a9d2f 100644 --- a/src/models/dedicated_database_extensions.rs +++ b/src/models/dedicated_database_extensions.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExtensions { /// List of installed extensions. #[serde(rename = "installed")] + #[serde(default = "default_installed")] pub installed: Vec, /// List of available extensions that can be installed. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: Vec, /// Curated metadata (display name, description, category) for each available /// extension. #[serde(rename = "metadata")] + #[serde(default = "default_metadata")] pub metadata: Vec, } +fn default_installed() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_available() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_metadata() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseExtensions { /// Get installed pub fn installed(&self) -> &Vec { diff --git a/src/models/dedicated_database_list.rs b/src/models/dedicated_database_list.rs index 7c68b07..40a0892 100644 --- a/src/models/dedicated_database_list.rs +++ b/src/models/dedicated_database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_member.rs b/src/models/dedicated_database_member.rs index df7f0d1..9ab4fee 100644 --- a/src/models/dedicated_database_member.rs +++ b/src/models/dedicated_database_member.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseMember { /// Member identifier. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology and this member has not /// been probed, so no member can be named the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Member pod status. Possible values: pending (configured but absent from the /// backend topology, so nothing is bringing it up), provisioning (pod missing @@ -21,6 +23,7 @@ pub struct DedicatedDatabaseMember { /// failed (Failed phase or CrashLoopBackOff container), or the lowercased pod /// phase reported by the cluster. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -41,6 +44,18 @@ pub struct DedicatedDatabaseMember { pub lag_seconds: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl DedicatedDatabaseMember { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation.rs b/src/models/dedicated_database_operation.rs index 4476b00..02c317c 100644 --- a/src/models/dedicated_database_operation.rs +++ b/src/models/dedicated_database_operation.rs @@ -8,24 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperation { /// Operation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Operation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID the operation ran against. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Operation type, such as provision, update, credentials-update, restore, /// pausing, resuming, failover, backup-create or cross-region-enable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Operation status. Possible values: queued (accepted and waiting to resume), /// running (in progress), completed (finished successfully), failed (ended in /// an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of times this operation has been attempted. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, /// Time the operation was requested, in ISO 8601 format. #[serde(rename = "requestedAt")] @@ -42,12 +48,46 @@ pub struct DedicatedDatabaseOperation { /// Machine-readable failure code. `Interrupted` marks an attempt that ended /// before its outcome could be confirmed. #[serde(rename = "errorCode")] + #[serde(default = "default_error_code")] pub error_code: String, /// Failure message if the operation failed. #[serde(rename = "errorMessage")] + #[serde(default = "default_error_message")] pub error_message: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + +fn default_error_code() -> String { + "".to_string() +} + +fn default_error_message() -> String { + "".to_string() +} + impl DedicatedDatabaseOperation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation_list.rs b/src/models/dedicated_database_operation_list.rs index 641721c..de4eb57 100644 --- a/src/models/dedicated_database_operation_list.rs +++ b/src/models/dedicated_database_operation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperationList { /// Total number of operations. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of operations. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_operations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseOperationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_pitr_windows.rs b/src/models/dedicated_database_pitr_windows.rs index 52b2fe5..59240b4 100644 --- a/src/models/dedicated_database_pitr_windows.rs +++ b/src/models/dedicated_database_pitr_windows.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePITRWindows { /// Earliest available recovery point. #[serde(rename = "earliest")] + #[serde(default = "default_earliest")] pub earliest: String, /// Latest available recovery point. #[serde(rename = "latest")] + #[serde(default = "default_latest")] pub latest: String, } +fn default_earliest() -> String { + "".to_string() +} + +fn default_latest() -> String { + "".to_string() +} + impl DedicatedDatabasePITRWindows { /// Get earliest pub fn earliest(&self) -> &String { diff --git a/src/models/dedicated_database_pooler.rs b/src/models/dedicated_database_pooler.rs index d1fa674..2d23de5 100644 --- a/src/models/dedicated_database_pooler.rs +++ b/src/models/dedicated_database_pooler.rs @@ -8,49 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePooler { /// Whether connection pooling is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Connection pool mode. Possible values: transaction (releases connections /// back to pool after each transaction), session (holds connections for the /// entire client session). #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Client-connection ceiling the pooler accepts. Enforced on MySQL and /// MariaDB; on PostgreSQL the pooler has no client cap, so this reports the /// database's advertised networkMaxConnections and cannot be set here. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Default pool size per user. #[serde(rename = "defaultPoolSize")] + #[serde(default = "default_default_pool_size")] pub default_pool_size: i64, /// Pooler listening port. #[serde(rename = "port")] + #[serde(default = "default_port")] pub port: i64, /// Whether SELECTs are routed to HA replicas while writes and locked reads /// stay on the primary. Active only when HA is enabled. #[serde(rename = "readWriteSplitting")] + #[serde(default = "default_read_write_splitting")] pub read_write_splitting: bool, /// Effective CPU request applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (5% of DB CPU, floor 100m) /// unless overridden. #[serde(rename = "poolerCpuRequest")] + #[serde(default = "default_pooler_cpu_request")] pub pooler_cpu_request: String, /// Effective CPU limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (10% of DB CPU, floor 200m) /// unless overridden. #[serde(rename = "poolerCpuLimit")] + #[serde(default = "default_pooler_cpu_limit")] pub pooler_cpu_limit: String, /// Effective memory request applied to the pooler sidecar container /// (Kubernetes quantity). Returns the proportional default (7.5% of DB memory, /// floor 64Mi) unless overridden. #[serde(rename = "poolerMemoryRequest")] + #[serde(default = "default_pooler_memory_request")] pub pooler_memory_request: String, /// Effective memory limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (15% of DB memory, floor 128Mi) /// unless overridden. #[serde(rename = "poolerMemoryLimit")] + #[serde(default = "default_pooler_memory_limit")] pub pooler_memory_limit: String, } +fn default_enabled() -> bool { + false +} + +fn default_mode() -> String { + "transaction".to_string() +} + +fn default_max_connections() -> i64 { + 100 +} + +fn default_default_pool_size() -> i64 { + 20 +} + +fn default_port() -> i64 { + 6432 +} + +fn default_read_write_splitting() -> bool { + false +} + +fn default_pooler_cpu_request() -> String { + "".to_string() +} + +fn default_pooler_cpu_limit() -> String { + "".to_string() +} + +fn default_pooler_memory_request() -> String { + "".to_string() +} + +fn default_pooler_memory_limit() -> String { + "".to_string() +} + impl DedicatedDatabasePooler { /// Get enabled pub fn enabled(&self) -> &bool { diff --git a/src/models/dedicated_database_replicas.rs b/src/models/dedicated_database_replicas.rs index 24bd468..701d8cc 100644 --- a/src/models/dedicated_database_replicas.rs +++ b/src/models/dedicated_database_replicas.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseReplicas { /// Number of configured replicas. Zero means high availability is disabled. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Requested replication sync mode. Possible values: async (asynchronous, /// fastest), sync (synchronous, strong consistency), quorum (quorum-based, /// majority of replicas must confirm). This is what was asked for; compare it /// with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. A value below the @@ -24,13 +26,16 @@ pub struct DedicatedDatabaseReplicas { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. Zero means writes are acknowledged locally. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -48,9 +53,34 @@ pub struct DedicatedDatabaseReplicas { pub sync_state_confirmed: Option, /// Per-pod statuses for the primary and every replica. #[serde(rename = "members")] + #[serde(default = "default_members")] pub members: Vec, } +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_members() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseReplicas { /// Get replicas pub fn replicas(&self) -> &i64 { diff --git a/src/models/dedicated_database_restoration.rs b/src/models/dedicated_database_restoration.rs index e52fefd..2ebee2e 100644 --- a/src/models/dedicated_database_restoration.rs +++ b/src/models/dedicated_database_restoration.rs @@ -8,45 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID being restored into. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Source database ID when restoring a backup into another database. #[serde(rename = "sourceDatabaseId")] - pub source_database_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_database_id: Option, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup ID used for restoration (null for PITR). #[serde(rename = "backupId")] - pub backup_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub backup_id: Option, /// Restoration type. Possible values: backup (restore from a specific backup /// snapshot), pitr (point-in-time recovery to a specific timestamp). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Restoration status. Possible values: pending (queued for processing), /// running (currently in progress), completed (successfully finished), failed /// (encountered an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Target time for PITR restoration in ISO 8601 format. #[serde(rename = "targetTime")] - pub target_time: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_time: Option, /// Restoration start time in ISO 8601 format. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Restoration completion time in ISO 8601 format. #[serde(rename = "completedAt")] - pub completed_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub completed_at: Option, /// Error message if restoration failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "backup".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseRestoration { /// Get id pub fn id(&self) -> &String { @@ -63,9 +103,15 @@ impl DedicatedDatabaseRestoration { &self.database_id } + /// Set source_database_id + pub fn set_source_database_id(mut self, source_database_id: String) -> Self { + self.source_database_id = Some(source_database_id); + self + } + /// Get source_database_id - pub fn source_database_id(&self) -> &String { - &self.source_database_id + pub fn source_database_id(&self) -> Option<&String> { + self.source_database_id.as_ref() } /// Get project_id @@ -73,9 +119,15 @@ impl DedicatedDatabaseRestoration { &self.project_id } + /// Set backup_id + pub fn set_backup_id(mut self, backup_id: String) -> Self { + self.backup_id = Some(backup_id); + self + } + /// Get backup_id - pub fn backup_id(&self) -> &String { - &self.backup_id + pub fn backup_id(&self) -> Option<&String> { + self.backup_id.as_ref() } /// Get r#type @@ -88,19 +140,37 @@ impl DedicatedDatabaseRestoration { &self.status } + /// Set target_time + pub fn set_target_time(mut self, target_time: String) -> Self { + self.target_time = Some(target_time); + self + } + /// Get target_time - pub fn target_time(&self) -> &String { - &self.target_time + pub fn target_time(&self) -> Option<&String> { + self.target_time.as_ref() + } + + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self } /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() + } + + /// Set completed_at + pub fn set_completed_at(mut self, completed_at: String) -> Self { + self.completed_at = Some(completed_at); + self } /// Get completed_at - pub fn completed_at(&self) -> &String { - &self.completed_at + pub fn completed_at(&self) -> Option<&String> { + self.completed_at.as_ref() } /// Get error @@ -119,14 +189,9 @@ mod tests { let _ = _model.id(); let _ = _model.created_at(); let _ = _model.database_id(); - let _ = _model.source_database_id(); let _ = _model.project_id(); - let _ = _model.backup_id(); let _ = _model.r#type(); let _ = _model.status(); - let _ = _model.target_time(); - let _ = _model.started_at(); - let _ = _model.completed_at(); let _ = _model.error(); } diff --git a/src/models/dedicated_database_restoration_list.rs b/src/models/dedicated_database_restoration_list.rs index 3d24d00..170ff62 100644 --- a/src/models/dedicated_database_restoration_list.rs +++ b/src/models/dedicated_database_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_specification.rs b/src/models/dedicated_database_specification.rs index 7dab746..f2bc9ee 100644 --- a/src/models/dedicated_database_specification.rs +++ b/src/models/dedicated_database_specification.rs @@ -8,49 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecification { /// Specification slug. Use this value when creating a dedicated database. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, /// Human readable specification name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Monthly price of the specification in USD. #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Price per GB of storage above the included amount, per month, in USD. #[serde(rename = "storageOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_overage_rate: Option, + #[serde(default = "default_storage_overage_rate")] + pub storage_overage_rate: f64, /// Price per GB of bandwidth above the included amount, per month, in USD. #[serde(rename = "bandwidthOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub bandwidth_overage_rate: Option, + #[serde(default = "default_bandwidth_overage_rate")] + pub bandwidth_overage_rate: f64, /// High availability replica price as a fraction of the specification price. #[serde(rename = "replicaRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub replica_rate: Option, + #[serde(default = "default_replica_rate")] + pub replica_rate: f64, /// Point-in-time recovery price as a fraction of the specification price. #[serde(rename = "pitrRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pitr_rate: Option, + #[serde(default = "default_pitr_rate")] + pub pitr_rate: f64, /// Allocated CPU in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Allocated memory in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Maximum number of concurrent connections. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Included storage in GB before overage charges apply. #[serde(rename = "includedStorage")] + #[serde(default = "default_included_storage")] pub included_storage: i64, /// Included bandwidth in GB before overage charges apply. #[serde(rename = "includedBandwidth")] + #[serde(default = "default_included_bandwidth")] pub included_bandwidth: i64, /// Whether the specification is available on the current plan. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_slug() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_storage_overage_rate() -> f64 { + 0.0 +} + +fn default_bandwidth_overage_rate() -> f64 { + 0.0 +} + +fn default_replica_rate() -> f64 { + 0.0 +} + +fn default_pitr_rate() -> f64 { + 0.0 +} + +fn default_cpu() -> i64 { + 0 +} + +fn default_memory() -> i64 { + 0 +} + +fn default_max_connections() -> i64 { + 0 +} + +fn default_included_storage() -> i64 { + 0 +} + +fn default_included_bandwidth() -> i64 { + 0 +} + +fn default_enabled() -> bool { + false +} + impl DedicatedDatabaseSpecification { /// Get slug pub fn slug(&self) -> &String { @@ -67,48 +128,24 @@ impl DedicatedDatabaseSpecification { &self.price } - /// Set storage_overage_rate - pub fn set_storage_overage_rate(mut self, storage_overage_rate: f64) -> Self { - self.storage_overage_rate = Some(storage_overage_rate); - self - } - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> Option<&f64> { - self.storage_overage_rate.as_ref() - } - - /// Set bandwidth_overage_rate - pub fn set_bandwidth_overage_rate(mut self, bandwidth_overage_rate: f64) -> Self { - self.bandwidth_overage_rate = Some(bandwidth_overage_rate); - self + pub fn storage_overage_rate(&self) -> &f64 { + &self.storage_overage_rate } /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> Option<&f64> { - self.bandwidth_overage_rate.as_ref() - } - - /// Set replica_rate - pub fn set_replica_rate(mut self, replica_rate: f64) -> Self { - self.replica_rate = Some(replica_rate); - self + pub fn bandwidth_overage_rate(&self) -> &f64 { + &self.bandwidth_overage_rate } /// Get replica_rate - pub fn replica_rate(&self) -> Option<&f64> { - self.replica_rate.as_ref() - } - - /// Set pitr_rate - pub fn set_pitr_rate(mut self, pitr_rate: f64) -> Self { - self.pitr_rate = Some(pitr_rate); - self + pub fn replica_rate(&self) -> &f64 { + &self.replica_rate } /// Get pitr_rate - pub fn pitr_rate(&self) -> Option<&f64> { - self.pitr_rate.as_ref() + pub fn pitr_rate(&self) -> &f64 { + &self.pitr_rate } /// Get cpu @@ -152,6 +189,10 @@ mod tests { let _ = _model.slug(); let _ = _model.name(); let _ = _model.price(); + let _ = _model.storage_overage_rate(); + let _ = _model.bandwidth_overage_rate(); + let _ = _model.replica_rate(); + let _ = _model.pitr_rate(); let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.max_connections(); diff --git a/src/models/dedicated_database_specification_list.rs b/src/models/dedicated_database_specification_list.rs index 2be3453..e86f829 100644 --- a/src/models/dedicated_database_specification_list.rs +++ b/src/models/dedicated_database_specification_list.rs @@ -8,13 +8,20 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecificationList { /// List of dedicated database specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, /// Total number of specifications. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, - /// Overage and add-on pricing shared across all specifications. - #[serde(rename = "pricing")] - pub pricing: crate::models::DedicatedDatabaseSpecificationPricing, +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_total() -> i64 { + 0 } impl DedicatedDatabaseSpecificationList { @@ -27,11 +34,6 @@ impl DedicatedDatabaseSpecificationList { pub fn total(&self) -> &i64 { &self.total } - - /// Get pricing - pub fn pricing(&self) -> &crate::models::DedicatedDatabaseSpecificationPricing { - &self.pricing - } } #[cfg(test)] @@ -43,7 +45,6 @@ mod tests { let _model = ::default(); let _ = _model.specifications(); let _ = _model.total(); - let _ = _model.pricing(); } #[test] diff --git a/src/models/dedicated_database_specification_pricing.rs b/src/models/dedicated_database_specification_pricing.rs deleted file mode 100644 index 0842526..0000000 --- a/src/models/dedicated_database_specification_pricing.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! DedicatedDatabaseSpecificationPricing model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// SpecificationPricing -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DedicatedDatabaseSpecificationPricing { - /// Price per GB of storage above the included amount, per month, in USD. - #[serde(rename = "storageOverageRate")] - pub storage_overage_rate: f64, - /// Price per GB of bandwidth above the included amount, per month, in USD. - #[serde(rename = "bandwidthOverageRate")] - pub bandwidth_overage_rate: f64, - /// High availability replica price as a fraction of the specification cost. - #[serde(rename = "replicaRate")] - pub replica_rate: f64, - /// Point-in-time recovery price as a fraction of the specification cost. - #[serde(rename = "pitrRate")] - pub pitr_rate: f64, -} - -impl DedicatedDatabaseSpecificationPricing { - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> &f64 { - &self.storage_overage_rate - } - - /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> &f64 { - &self.bandwidth_overage_rate - } - - /// Get replica_rate - pub fn replica_rate(&self) -> &f64 { - &self.replica_rate - } - - /// Get pitr_rate - pub fn pitr_rate(&self) -> &f64 { - &self.pitr_rate - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dedicated_database_specification_pricing_creation() { - let _model = ::default(); - let _ = _model.storage_overage_rate(); - let _ = _model.bandwidth_overage_rate(); - let _ = _model.replica_rate(); - let _ = _model.pitr_rate(); - } - - #[test] - fn test_dedicated_database_specification_pricing_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = - serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/deployment.rs b/src/models/deployment.rs index 2da7e6f..78539b5 100644 --- a/src/models/deployment.rs +++ b/src/models/deployment.rs @@ -8,45 +8,59 @@ use serde::{Deserialize, Serialize}; pub struct Deployment { /// Deployment ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Deployment creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Deployment update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Type of deployment. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// The entrypoint file to use to execute the deployment code. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The code size in bytes. #[serde(rename = "sourceSize")] + #[serde(default = "default_source_size")] pub source_size: i64, /// The build output size in bytes. #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// The total size in bytes (source and build output). #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, /// The current build ID. #[serde(rename = "buildId")] + #[serde(default = "default_build_id")] pub build_id: String, /// Whether the deployment should be automatically activated. #[serde(rename = "activate")] + #[serde(default = "default_activate")] pub activate: bool, /// Screenshot with light theme preference file ID. #[serde(rename = "screenshotLight")] + #[serde(default = "default_screenshot_light")] pub screenshot_light: String, /// Screenshot with dark theme preference file ID. #[serde(rename = "screenshotDark")] + #[serde(default = "default_screenshot_dark")] pub screenshot_dark: String, /// The deployment status. Possible values are "waiting", "processing", /// "building", "ready", "canceled" and "failed". @@ -54,42 +68,158 @@ pub struct Deployment { pub status: crate::enums::DeploymentStatus, /// The build logs. #[serde(rename = "buildLogs")] + #[serde(default = "default_build_logs")] pub build_logs: String, /// The current build time in seconds. #[serde(rename = "buildDuration")] + #[serde(default = "default_build_duration")] pub build_duration: i64, /// The name of the vcs provider repository #[serde(rename = "providerRepositoryName")] + #[serde(default = "default_provider_repository_name")] pub provider_repository_name: String, /// The name of the vcs provider repository owner #[serde(rename = "providerRepositoryOwner")] + #[serde(default = "default_provider_repository_owner")] pub provider_repository_owner: String, /// The url of the vcs provider repository #[serde(rename = "providerRepositoryUrl")] + #[serde(default = "default_provider_repository_url")] pub provider_repository_url: String, /// The commit hash of the vcs commit #[serde(rename = "providerCommitHash")] + #[serde(default = "default_provider_commit_hash")] pub provider_commit_hash: String, /// The url of vcs commit author #[serde(rename = "providerCommitAuthorUrl")] + #[serde(default = "default_provider_commit_author_url")] pub provider_commit_author_url: String, /// The name of vcs commit author #[serde(rename = "providerCommitAuthor")] + #[serde(default = "default_provider_commit_author")] pub provider_commit_author: String, /// The commit message #[serde(rename = "providerCommitMessage")] + #[serde(default = "default_provider_commit_message")] pub provider_commit_message: String, /// The url of the vcs commit #[serde(rename = "providerCommitUrl")] + #[serde(default = "default_provider_commit_url")] pub provider_commit_url: String, /// The branch of the vcs repository #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// The branch of the vcs repository #[serde(rename = "providerBranchUrl")] + #[serde(default = "default_provider_branch_url")] pub provider_branch_url: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_source_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_total_size() -> i64 { + 0 +} + +fn default_build_id() -> String { + "".to_string() +} + +fn default_activate() -> bool { + false +} + +fn default_screenshot_light() -> String { + "".to_string() +} + +fn default_screenshot_dark() -> String { + "".to_string() +} + +fn default_build_logs() -> String { + "".to_string() +} + +fn default_build_duration() -> i64 { + 0 +} + +fn default_provider_repository_name() -> String { + "".to_string() +} + +fn default_provider_repository_owner() -> String { + "".to_string() +} + +fn default_provider_repository_url() -> String { + "".to_string() +} + +fn default_provider_commit_hash() -> String { + "".to_string() +} + +fn default_provider_commit_author_url() -> String { + "".to_string() +} + +fn default_provider_commit_author() -> String { + "".to_string() +} + +fn default_provider_commit_message() -> String { + "".to_string() +} + +fn default_provider_commit_url() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_branch_url() -> String { + "".to_string() +} + impl Deployment { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/deployment_list.rs b/src/models/deployment_list.rs index 5ee6ea7..f58b0b2 100644 --- a/src/models/deployment_list.rs +++ b/src/models/deployment_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DeploymentList { /// Total number of deployments that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of deployments. #[serde(rename = "deployments")] + #[serde(default = "default_deployments")] pub deployments: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_deployments() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DeploymentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dev_key.rs b/src/models/dev_key.rs deleted file mode 100644 index 7b5ba1f..0000000 --- a/src/models/dev_key.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! DevKey model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// DevKey -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DevKey { - /// Key ID. - #[serde(rename = "$id")] - pub id: String, - /// Key creation date in ISO 8601 format. - #[serde(rename = "$createdAt")] - pub created_at: String, - /// Key update date in ISO 8601 format. - #[serde(rename = "$updatedAt")] - pub updated_at: String, - /// Key name. - #[serde(rename = "name")] - pub name: String, - /// Key expiration date in ISO 8601 format. - #[serde(rename = "expire")] - pub expire: String, - /// Secret key. - #[serde(rename = "secret")] - pub secret: String, - /// Most recent access date in ISO 8601 format. This attribute is only updated - /// again after 24 hours. - #[serde(rename = "accessedAt")] - pub accessed_at: String, - /// List of SDK user agents that used this key. - #[serde(rename = "sdks")] - pub sdks: Vec, -} - -impl DevKey { - /// Get id - pub fn id(&self) -> &String { - &self.id - } - - /// Get created_at - pub fn created_at(&self) -> &String { - &self.created_at - } - - /// Get updated_at - pub fn updated_at(&self) -> &String { - &self.updated_at - } - - /// Get name - pub fn name(&self) -> &String { - &self.name - } - - /// Get expire - pub fn expire(&self) -> &String { - &self.expire - } - - /// Get secret - pub fn secret(&self) -> &String { - &self.secret - } - - /// Get accessed_at - pub fn accessed_at(&self) -> &String { - &self.accessed_at - } - - /// Get sdks - pub fn sdks(&self) -> &Vec { - &self.sdks - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dev_key_creation() { - let _model = ::default(); - let _ = _model.id(); - let _ = _model.created_at(); - let _ = _model.updated_at(); - let _ = _model.name(); - let _ = _model.expire(); - let _ = _model.secret(); - let _ = _model.accessed_at(); - let _ = _model.sdks(); - } - - #[test] - fn test_dev_key_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/document.rs b/src/models/document.rs index 67c4a9c..0976976 100644 --- a/src/models/document.rs +++ b/src/models/document.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Document { /// Document ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Document sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Collection ID. #[serde(rename = "$collectionId")] + #[serde(default = "default_collection_id")] pub collection_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Document creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Document update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Document permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_collection_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Document { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/document_list.rs b/src/models/document_list.rs index bf9ba60..55f3143 100644 --- a/src/models/document_list.rs +++ b/src/models/document_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DocumentList { /// Total number of documents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of documents. #[serde(rename = "documents")] + #[serde(default = "default_documents")] pub documents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_documents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DocumentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/email_template.rs b/src/models/email_template.rs index 3236650..4ff064a 100644 --- a/src/models/email_template.rs +++ b/src/models/email_template.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplate { /// Template type #[serde(rename = "templateId")] + #[serde(default = "default_template_id")] pub template_id: String, /// Template locale #[serde(rename = "locale")] + #[serde(default = "default_locale")] pub locale: String, /// Template message #[serde(rename = "message")] + #[serde(default = "default_message")] pub message: String, /// Name of the sender #[serde(rename = "senderName")] + #[serde(default = "default_sender_name")] pub sender_name: String, /// Email of the sender #[serde(rename = "senderEmail")] + #[serde(default = "default_sender_email")] pub sender_email: String, /// Reply to email address #[serde(rename = "replyToEmail")] + #[serde(default = "default_reply_to_email")] pub reply_to_email: String, /// Reply to name #[serde(rename = "replyToName")] + #[serde(default = "default_reply_to_name")] pub reply_to_name: String, /// Email subject #[serde(rename = "subject")] + #[serde(default = "default_subject")] pub subject: String, } +fn default_template_id() -> String { + "".to_string() +} + +fn default_locale() -> String { + "".to_string() +} + +fn default_message() -> String { + "".to_string() +} + +fn default_sender_name() -> String { + "".to_string() +} + +fn default_sender_email() -> String { + "".to_string() +} + +fn default_reply_to_email() -> String { + "".to_string() +} + +fn default_reply_to_name() -> String { + "".to_string() +} + +fn default_subject() -> String { + "".to_string() +} + impl EmailTemplate { /// Get template_id pub fn template_id(&self) -> &String { diff --git a/src/models/email_template_list.rs b/src/models/email_template_list.rs index 02dbf9a..6d93da2 100644 --- a/src/models/email_template_list.rs +++ b/src/models/email_template_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplateList { /// Total number of templates that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of templates. #[serde(rename = "templates")] + #[serde(default = "default_templates")] pub templates: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_templates() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmailTemplateList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/embedding.rs b/src/models/embedding.rs index 1e26677..041e14d 100644 --- a/src/models/embedding.rs +++ b/src/models/embedding.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Embedding { /// Embedding model used to generate embeddings. #[serde(rename = "model")] + #[serde(default = "default_model")] pub model: String, /// Number of dimensions for each embedding vector. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, /// Embedding vector values. If an error occurs, this will be an empty array. #[serde(rename = "embedding")] + #[serde(default = "default_embedding")] pub embedding: Vec, /// Error message if embedding generation fails. Empty string if no error. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_model() -> String { + "".to_string() +} + +fn default_dimension() -> i64 { + 0 +} + +fn default_embedding() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_error() -> String { + "".to_string() +} + impl Embedding { /// Get model pub fn model(&self) -> &String { diff --git a/src/models/embedding_list.rs b/src/models/embedding_list.rs index 65f3074..25c9cbf 100644 --- a/src/models/embedding_list.rs +++ b/src/models/embedding_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmbeddingList { /// Total number of embeddings that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of embeddings. #[serde(rename = "embeddings")] + #[serde(default = "default_embeddings")] pub embeddings: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_embeddings() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmbeddingList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/ephemeral_key.rs b/src/models/ephemeral_key.rs index 091da9c..6abef19 100644 --- a/src/models/ephemeral_key.rs +++ b/src/models/ephemeral_key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct EphemeralKey { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EphemeralKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution.rs b/src/models/execution.rs index 9591343..46e3963 100644 --- a/src/models/execution.rs +++ b/src/models/execution.rs @@ -8,24 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Execution { /// Execution ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Execution creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Execution update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution roles. #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Function or site ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Execution resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: crate::enums::ExecutionResourceType, /// Deployment ID used to create the execution. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// The trigger that caused the resource to execute. Possible values can be: /// `http`, `schedule`, or `event`. @@ -37,39 +44,48 @@ pub struct Execution { pub status: crate::enums::ExecutionStatus, /// HTTP request method type. #[serde(rename = "requestMethod")] + #[serde(default = "default_request_method")] pub request_method: String, /// HTTP request path and query. #[serde(rename = "requestPath")] + #[serde(default = "default_request_path")] pub request_path: String, /// HTTP request headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "requestHeaders")] + #[serde(default = "default_request_headers")] pub request_headers: Vec, /// HTTP response status code. #[serde(rename = "responseStatusCode")] + #[serde(default = "default_response_status_code")] pub response_status_code: i64, /// HTTP response body. This will return empty unless execution is created as /// synchronous. #[serde(rename = "responseBody")] + #[serde(default = "default_response_body")] pub response_body: String, /// HTTP response headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "responseHeaders")] + #[serde(default = "default_response_headers")] pub response_headers: Vec, /// Resource logs. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Resource errors. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "errors")] + #[serde(default = "default_errors")] pub errors: String, - /// Resource(function/site) execution duration in seconds. + /// Total time the resource(function/site) took to respond, in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: f64, /// The scheduled time for execution. If left empty, execution will be queued /// immediately. @@ -78,6 +94,70 @@ pub struct Execution { pub scheduled_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> crate::enums::ExecutionResourceType { + serde_json::from_value(serde_json::json!("functions")).unwrap() +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_request_method() -> String { + "".to_string() +} + +fn default_request_path() -> String { + "".to_string() +} + +fn default_request_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_response_status_code() -> i64 { + 0 +} + +fn default_response_body() -> String { + "".to_string() +} + +fn default_response_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_errors() -> String { + "".to_string() +} + +fn default_duration() -> f64 { + 0.0 +} + impl Execution { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution_list.rs b/src/models/execution_list.rs index 85fa76f..d30bc6c 100644 --- a/src/models/execution_list.rs +++ b/src/models/execution_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ExecutionList { /// Total number of executions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of executions. #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_executions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ExecutionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/file.rs b/src/models/file.rs index 1310f94..1f95426 100644 --- a/src/models/file.rs +++ b/src/models/file.rs @@ -8,58 +8,138 @@ use serde::{Deserialize, Serialize}; pub struct File { /// File ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket ID. #[serde(rename = "bucketId")] + #[serde(default = "default_bucket_id")] pub bucket_id: String, /// File creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// File update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// File permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// File name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Virtual folder containing the file, with a trailing slash. Empty for the /// bucket root. #[serde(rename = "folder")] + #[serde(default = "default_folder")] pub folder: String, /// Full virtual path of the file: the folder followed by the file name. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// File MD5 signature. #[serde(rename = "signature")] + #[serde(default = "default_signature")] pub signature: String, /// File mime type. #[serde(rename = "mimeType")] + #[serde(default = "default_mime_type")] pub mime_type: String, /// File original size in bytes. #[serde(rename = "sizeOriginal")] + #[serde(default = "default_size_original")] pub size_original: i64, /// File actual stored size in bytes after compression and/or encryption. #[serde(rename = "sizeActual")] + #[serde(default = "default_size_actual")] pub size_actual: i64, /// Total number of chunks available #[serde(rename = "chunksTotal")] + #[serde(default = "default_chunks_total")] pub chunks_total: i64, /// Total number of chunks uploaded #[serde(rename = "chunksUploaded")] + #[serde(default = "default_chunks_uploaded")] pub chunks_uploaded: i64, /// Whether file contents are encrypted at rest. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Compression algorithm used for the file. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_bucket_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_folder() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_signature() -> String { + "".to_string() +} + +fn default_mime_type() -> String { + "".to_string() +} + +fn default_size_original() -> i64 { + 0 +} + +fn default_size_actual() -> i64 { + 0 +} + +fn default_chunks_total() -> i64 { + 0 +} + +fn default_chunks_uploaded() -> i64 { + 0 +} + +fn default_encryption() -> bool { + false +} + +fn default_compression() -> String { + "none".to_string() +} + impl File { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/file_list.rs b/src/models/file_list.rs index bc9f598..06a0bec 100644 --- a/src/models/file_list.rs +++ b/src/models/file_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FileList { /// Total number of files that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of files. #[serde(rename = "files")] + #[serde(default = "default_files")] pub files: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_files() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FileList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/framework.rs b/src/models/framework.rs index fbc7a82..2f04803 100644 --- a/src/models/framework.rs +++ b/src/models/framework.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct Framework { /// Framework key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Framework Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Default runtime version. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// List of supported runtime versions. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, /// List of supported adapters. #[serde(rename = "adapters")] + #[serde(default = "default_adapters")] pub adapters: Vec, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_adapters() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Framework { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_adapter.rs b/src/models/framework_adapter.rs index 5ffe882..d945c32 100644 --- a/src/models/framework_adapter.rs +++ b/src/models/framework_adapter.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkAdapter { /// Adapter key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Default command to download dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// Default command to build site into output directory. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Default output directory of build. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Name of fallback file to use instead of 404 page. If null, Appwrite 404 /// page will be displayed. @@ -25,6 +29,22 @@ pub struct FrameworkAdapter { pub fallback_file: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + impl FrameworkAdapter { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_list.rs b/src/models/framework_list.rs index 9d8570f..fd7e484 100644 --- a/src/models/framework_list.rs +++ b/src/models/framework_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkList { /// Total number of frameworks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of frameworks. #[serde(rename = "frameworks")] + #[serde(default = "default_frameworks")] pub frameworks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_frameworks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FrameworkList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/function.rs b/src/models/function.rs index 06374cd..1ec588b 100644 --- a/src/models/function.rs +++ b/src/models/function.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct Function { /// Function ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Function creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Function update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution permissions. #[serde(rename = "execute")] + #[serde(default = "default_execute")] pub execute: Vec, /// Function name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Function enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the function deployed with the latest configuration? This is set to /// false if you've changed an environment variables, entrypoint, commands, or /// other settings that needs redeploy to be applied. When the value is false, /// redeploy the function to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, executions will exclude logs and errors, and will be /// slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Function execution and build runtime. #[serde(rename = "runtime")] + #[serde(default = "default_runtime")] pub runtime: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Function's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Function's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Function variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Function trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Function execution schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Minutes between scheduled executions. 0 when the function has no interval. #[serde(rename = "interval")] @@ -75,49 +94,190 @@ pub struct Function { pub interval: Option, /// Function execution timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The entrypoint file used to execute the deployment. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The build command used to build the deployment. #[serde(rename = "commands")] + #[serde(default = "default_commands")] pub commands: String, /// Version of Open Runtimes used for the function. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Function VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to function in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_execute() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_runtime() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_schedule() -> String { + "".to_string() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_commands() -> String { + "".to_string() +} + +fn default_version() -> String { + "v5".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + impl Function { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/function_list.rs b/src/models/function_list.rs index ff9a37d..ee30315 100644 --- a/src/models/function_list.rs +++ b/src/models/function_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FunctionList { /// Total number of functions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of functions. #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_functions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FunctionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/headers.rs b/src/models/headers.rs index 87a2b64..2aed2bc 100644 --- a/src/models/headers.rs +++ b/src/models/headers.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Headers { /// Header name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Header value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + impl Headers { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/identity.rs b/src/models/identity.rs index aca8541..bc00cf8 100644 --- a/src/models/identity.rs +++ b/src/models/identity.rs @@ -8,39 +8,93 @@ use serde::{Deserialize, Serialize}; pub struct Identity { /// Identity ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Identity creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Identity update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Identity Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// ID of the User in the Identity Provider. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Email of the User in the Identity Provider. #[serde(rename = "providerEmail")] + #[serde(default = "default_provider_email")] pub provider_email: String, /// Identity Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Identity Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// Identity Provider ID token (JWT) from the most recent native sign-in. Empty /// for identities created through the browser OAuth2 flow. #[serde(rename = "providerIdToken")] - #[serde(skip_serializing_if = "Option::is_none")] - pub provider_id_token: Option, + #[serde(default = "default_provider_id_token")] + pub provider_id_token: String, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_email() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_provider_id_token() -> String { + "".to_string() } impl Identity { @@ -94,15 +148,9 @@ impl Identity { &self.provider_refresh_token } - /// Set provider_id_token - pub fn set_provider_id_token(mut self, provider_id_token: String) -> Self { - self.provider_id_token = Some(provider_id_token); - self - } - /// Get provider_id_token - pub fn provider_id_token(&self) -> Option<&String> { - self.provider_id_token.as_ref() + pub fn provider_id_token(&self) -> &String { + &self.provider_id_token } } @@ -123,6 +171,7 @@ mod tests { let _ = _model.provider_access_token(); let _ = _model.provider_access_token_expiry(); let _ = _model.provider_refresh_token(); + let _ = _model.provider_id_token(); } #[test] diff --git a/src/models/identity_list.rs b/src/models/identity_list.rs index b8cca8a..951990d 100644 --- a/src/models/identity_list.rs +++ b/src/models/identity_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IdentityList { /// Total number of identities that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of identities. #[serde(rename = "identities")] + #[serde(default = "default_identities")] pub identities: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_identities() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IdentityList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/index.rs b/src/models/index.rs index d18b386..b3865e8 100644 --- a/src/models/index.rs +++ b/src/models/index.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Index { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -28,12 +33,15 @@ pub struct Index { /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Index attributes length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +49,38 @@ pub struct Index { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Index { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/index_list.rs b/src/models/index_list.rs index 48eec9e..39499dc 100644 --- a/src/models/index_list.rs +++ b/src/models/index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/insight.rs b/src/models/insight.rs index 937d6f7..e514aca 100644 --- a/src/models/insight.rs +++ b/src/models/insight.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct Insight { /// Insight ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Insight creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Insight update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Parent report ID. Insights always belong to a report. #[serde(rename = "reportId")] + #[serde(default = "default_report_id")] pub report_id: String, /// Insight type. One of databaseIndex (legacy), tablesDBIndex, /// documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, @@ -25,36 +29,46 @@ pub struct Insight { /// (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or /// vectorsDB.createIndex). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Insight severity. One of info, warning, critical. #[serde(rename = "severity")] + #[serde(default = "default_severity")] pub severity: String, /// Insight status. One of active, dismissed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Type of the resource the insight is about. Plural noun, e.g. databases, /// sites, functions. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of the resource the insight is about. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Plural noun for the parent resource that contains the insight's resource, /// e.g. an insight about a column index on a table → resourceType=indexes, /// parentResourceType=tables. Empty when the resource has no parent. #[serde(rename = "parentResourceType")] + #[serde(default = "default_parent_resource_type")] pub parent_resource_type: String, /// ID of the parent resource. Empty when the resource has no parent. #[serde(rename = "parentResourceId")] + #[serde(default = "default_parent_resource_id")] pub parent_resource_id: String, /// Insight title. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Short markdown summary describing the insight. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// List of call-to-action buttons attached to this insight. #[serde(rename = "ctas")] + #[serde(default = "default_ctas")] pub ctas: Vec, /// Time the insight was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -71,6 +85,62 @@ pub struct Insight { pub dismissed_by: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_report_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_severity() -> String { + "info".to_string() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_parent_resource_type() -> String { + "".to_string() +} + +fn default_parent_resource_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_ctas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Insight { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/insight_cta.rs b/src/models/insight_cta.rs index 6a3b719..d96fa8a 100644 --- a/src/models/insight_cta.rs +++ b/src/models/insight_cta.rs @@ -8,24 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct InsightCTA { /// Human-readable label for the CTA, used in UI. #[serde(rename = "label")] + #[serde(default = "default_label")] pub label: String, /// Public API service (SDK namespace) the client should invoke. Must match the /// engine that owns the resource — for index suggestions: databases /// (legacy), tablesDB, documentsDB, or vectorsDB. #[serde(rename = "service")] + #[serde(default = "default_service")] pub service: String, /// Public API method on the chosen service the client should invoke when this /// CTA is triggered. #[serde(rename = "method")] + #[serde(default = "default_method")] pub method: String, /// Parameter map the client should pass to the service method when this CTA is /// triggered. Keys match the target API's parameter names (e.g. /// databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes /// for the legacy Databases API). #[serde(rename = "params")] + #[serde(default = "default_params")] pub params: serde_json::Value, } +fn default_label() -> String { + "".to_string() +} + +fn default_service() -> String { + "".to_string() +} + +fn default_method() -> String { + "".to_string() +} + +fn default_params() -> serde_json::Value { + serde_json::json!({}) +} + impl InsightCTA { /// Get label pub fn label(&self) -> &String { diff --git a/src/models/insight_list.rs b/src/models/insight_list.rs index 54b229c..e5b6d1a 100644 --- a/src/models/insight_list.rs +++ b/src/models/insight_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct InsightList { /// Total number of insights that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of insights. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl InsightList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/jwt.rs b/src/models/jwt.rs index 8482207..535cf61 100644 --- a/src/models/jwt.rs +++ b/src/models/jwt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Jwt { /// JWT encoded string. #[serde(rename = "jwt")] + #[serde(default = "default_jwt")] pub jwt: String, } +fn default_jwt() -> String { + "".to_string() +} + impl Jwt { /// Get jwt pub fn jwt(&self) -> &String { diff --git a/src/models/key.rs b/src/models/key.rs index 109b8d5..06b83c7 100644 --- a/src/models/key.rs +++ b/src/models/key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct Key { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Key { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/key_list.rs b/src/models/key_list.rs index 0cad143..767cf5e 100644 --- a/src/models/key_list.rs +++ b/src/models/key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct KeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl KeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/language.rs b/src/models/language.rs index bef7ec4..fd3d530 100644 --- a/src/models/language.rs +++ b/src/models/language.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Language { /// Language name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Language two-character ISO 639-1 codes. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Language native name. #[serde(rename = "nativeName")] + #[serde(default = "default_native_name")] pub native_name: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + +fn default_native_name() -> String { + "".to_string() +} + impl Language { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/language_list.rs b/src/models/language_list.rs index 42d79d9..9993952 100644 --- a/src/models/language_list.rs +++ b/src/models/language_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LanguageList { /// Total number of languages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of languages. #[serde(rename = "languages")] + #[serde(default = "default_languages")] pub languages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_languages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LanguageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/locale.rs b/src/models/locale.rs index 08b7f02..ecd0d0d 100644 --- a/src/models/locale.rs +++ b/src/models/locale.rs @@ -8,28 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Locale { /// User IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) /// two-character format #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. This field support localization. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. A two character continent code "AF" for Africa, "AN" for /// Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" /// for Oceania, and "SA" for South America. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// Continent name. This field support localization. #[serde(rename = "continent")] + #[serde(default = "default_continent")] pub continent: String, /// True if country is part of the European Union. #[serde(rename = "eu")] + #[serde(default = "default_eu")] pub eu: bool, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// City #[serde(rename = "city")] @@ -77,6 +84,34 @@ pub struct Locale { pub connection_organization: Option, } +fn default_ip() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_continent() -> String { + "".to_string() +} + +fn default_eu() -> bool { + false +} + +fn default_currency() -> String { + "".to_string() +} + impl Locale { /// Get ip pub fn ip(&self) -> &String { diff --git a/src/models/locale_code.rs b/src/models/locale_code.rs index 389f8a2..84b8601 100644 --- a/src/models/locale_code.rs +++ b/src/models/locale_code.rs @@ -9,12 +9,22 @@ pub struct LocaleCode { /// Locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Locale name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + impl LocaleCode { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/locale_code_list.rs b/src/models/locale_code_list.rs index e8e2ebb..8314d75 100644 --- a/src/models/locale_code_list.rs +++ b/src/models/locale_code_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LocaleCodeList { /// Total number of localeCodes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of localeCodes. #[serde(rename = "localeCodes")] + #[serde(default = "default_locale_codes")] pub locale_codes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_locale_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LocaleCodeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/log.rs b/src/models/log.rs deleted file mode 100644 index c62709d..0000000 --- a/src/models/log.rs +++ /dev/null @@ -1,235 +0,0 @@ -//! Log model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Log -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct Log { - /// Event name. - #[serde(rename = "event")] - pub event: String, - /// User ID of the actor recorded for this log. During impersonation, this is - /// the original impersonator, not the impersonated target user. - #[serde(rename = "userId")] - pub user_id: String, - /// User email of the actor recorded for this log. During impersonation, this - /// is the original impersonator. - #[serde(rename = "userEmail")] - pub user_email: String, - /// User name of the actor recorded for this log. During impersonation, this is - /// the original impersonator. - #[serde(rename = "userName")] - pub user_name: String, - /// API mode when event triggered. - #[serde(rename = "mode")] - pub mode: String, - /// User type who triggered the audit log. Possible values: user, admin, guest, - /// hidden, keyProject, keyAccount, keyOrganization. - #[serde(rename = "userType")] - pub user_type: String, - /// IP session in use when the session was created. - #[serde(rename = "ip")] - pub ip: String, - /// Log creation date in ISO 8601 format. - #[serde(rename = "time")] - pub time: String, - /// Operating system code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - #[serde(rename = "osCode")] - pub os_code: String, - /// Operating system name. - #[serde(rename = "osName")] - pub os_name: String, - /// Operating system version. - #[serde(rename = "osVersion")] - pub os_version: String, - /// Client type. - #[serde(rename = "clientType")] - pub client_type: String, - /// Client code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - #[serde(rename = "clientCode")] - pub client_code: String, - /// Client name. - #[serde(rename = "clientName")] - pub client_name: String, - /// Client version. - #[serde(rename = "clientVersion")] - pub client_version: String, - /// Client engine name. - #[serde(rename = "clientEngine")] - pub client_engine: String, - /// Client engine name. - #[serde(rename = "clientEngineVersion")] - pub client_engine_version: String, - /// Device name. - #[serde(rename = "deviceName")] - pub device_name: String, - /// Device brand name. - #[serde(rename = "deviceBrand")] - pub device_brand: String, - /// Device model name. - #[serde(rename = "deviceModel")] - pub device_model: String, - /// Country two-character ISO 3166-1 alpha code. - #[serde(rename = "countryCode")] - pub country_code: String, - /// Country name. - #[serde(rename = "countryName")] - pub country_name: String, -} - -impl Log { - /// Get event - pub fn event(&self) -> &String { - &self.event - } - - /// Get user_id - pub fn user_id(&self) -> &String { - &self.user_id - } - - /// Get user_email - pub fn user_email(&self) -> &String { - &self.user_email - } - - /// Get user_name - pub fn user_name(&self) -> &String { - &self.user_name - } - - /// Get mode - pub fn mode(&self) -> &String { - &self.mode - } - - /// Get user_type - pub fn user_type(&self) -> &String { - &self.user_type - } - - /// Get ip - pub fn ip(&self) -> &String { - &self.ip - } - - /// Get time - pub fn time(&self) -> &String { - &self.time - } - - /// Get os_code - pub fn os_code(&self) -> &String { - &self.os_code - } - - /// Get os_name - pub fn os_name(&self) -> &String { - &self.os_name - } - - /// Get os_version - pub fn os_version(&self) -> &String { - &self.os_version - } - - /// Get client_type - pub fn client_type(&self) -> &String { - &self.client_type - } - - /// Get client_code - pub fn client_code(&self) -> &String { - &self.client_code - } - - /// Get client_name - pub fn client_name(&self) -> &String { - &self.client_name - } - - /// Get client_version - pub fn client_version(&self) -> &String { - &self.client_version - } - - /// Get client_engine - pub fn client_engine(&self) -> &String { - &self.client_engine - } - - /// Get client_engine_version - pub fn client_engine_version(&self) -> &String { - &self.client_engine_version - } - - /// Get device_name - pub fn device_name(&self) -> &String { - &self.device_name - } - - /// Get device_brand - pub fn device_brand(&self) -> &String { - &self.device_brand - } - - /// Get device_model - pub fn device_model(&self) -> &String { - &self.device_model - } - - /// Get country_code - pub fn country_code(&self) -> &String { - &self.country_code - } - - /// Get country_name - pub fn country_name(&self) -> &String { - &self.country_name - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_creation() { - let _model = ::default(); - let _ = _model.event(); - let _ = _model.user_id(); - let _ = _model.user_email(); - let _ = _model.user_name(); - let _ = _model.mode(); - let _ = _model.user_type(); - let _ = _model.ip(); - let _ = _model.time(); - let _ = _model.os_code(); - let _ = _model.os_name(); - let _ = _model.os_version(); - let _ = _model.client_type(); - let _ = _model.client_code(); - let _ = _model.client_name(); - let _ = _model.client_version(); - let _ = _model.client_engine(); - let _ = _model.client_engine_version(); - let _ = _model.device_name(); - let _ = _model.device_brand(); - let _ = _model.device_model(); - let _ = _model.country_code(); - let _ = _model.country_name(); - } - - #[test] - fn test_log_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/log_list.rs b/src/models/log_list.rs deleted file mode 100644 index 8215ec2..0000000 --- a/src/models/log_list.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! LogList model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Logs List -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct LogList { - /// Total number of logs that matched your query. - #[serde(rename = "total")] - pub total: i64, - /// List of logs. - #[serde(rename = "logs")] - pub logs: Vec, -} - -impl LogList { - /// Get total - pub fn total(&self) -> &i64 { - &self.total - } - - /// Get logs - pub fn logs(&self) -> &Vec { - &self.logs - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_list_creation() { - let _model = ::default(); - let _ = _model.total(); - let _ = _model.logs(); - } - - #[test] - fn test_log_list_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/membership.rs b/src/models/membership.rs index da724ca..bc0954e 100644 --- a/src/models/membership.rs +++ b/src/models/membership.rs @@ -8,59 +8,134 @@ use serde::{Deserialize, Serialize}; pub struct Membership { /// Membership ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Membership creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Membership update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User name. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// User email address. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: String, /// User phone number. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Team name. #[serde(rename = "teamName")] + #[serde(default = "default_team_name")] pub team_name: String, /// Date, the user has been invited to join the team in ISO 8601 format. #[serde(rename = "invited")] + #[serde(default = "default_invited")] pub invited: String, /// Date, the user has accepted the invitation to join the team in ISO 8601 /// format. #[serde(rename = "joined")] + #[serde(default = "default_joined")] pub joined: String, /// User confirmation status, true if the user has joined the team or false /// otherwise. #[serde(rename = "confirm")] + #[serde(default = "default_confirm")] pub confirm: bool, /// Multi factor authentication status, true if the user has MFA enabled or /// false otherwise. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// Most recent access date in ISO 8601 format. Show this attribute by toggling /// membership privacy in the Console. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: String, /// User list of roles #[serde(rename = "roles")] + #[serde(default = "default_roles")] pub roles: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_user_email() -> String { + "".to_string() +} + +fn default_user_phone() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_team_name() -> String { + "".to_string() +} + +fn default_invited() -> String { + "".to_string() +} + +fn default_joined() -> String { + "".to_string() +} + +fn default_confirm() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> String { + "".to_string() +} + +fn default_roles() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Membership { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/membership_list.rs b/src/models/membership_list.rs index 628a569..a5c2d03 100644 --- a/src/models/membership_list.rs +++ b/src/models/membership_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MembershipList { /// Total number of memberships that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of memberships. #[serde(rename = "memberships")] + #[serde(default = "default_memberships")] pub memberships: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_memberships() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MembershipList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/message.rs b/src/models/message.rs index 554149b..29880eb 100644 --- a/src/models/message.rs +++ b/src/models/message.rs @@ -8,24 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Message { /// Message ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Message creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Message update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Message provider type. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// Topic IDs set as recipients. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, /// User IDs set as recipients. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, /// Target IDs set as recipients. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// The scheduled time for message. #[serde(rename = "scheduledAt")] @@ -41,15 +48,58 @@ pub struct Message { pub delivery_errors: Option>, /// Number of recipients the message was delivered to. #[serde(rename = "deliveredTotal")] + #[serde(default = "default_delivered_total")] pub delivered_total: i64, /// Data of the message. #[serde(rename = "data")] + #[serde(default = "default_data")] pub data: serde_json::Value, /// Status of delivery. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::MessageStatus, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_delivered_total() -> i64 { + 0 +} + +fn default_data() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_status() -> crate::enums::MessageStatus { + serde_json::from_value(serde_json::json!("draft")).unwrap() +} + impl Message { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/message_list.rs b/src/models/message_list.rs index de470cb..628ae06 100644 --- a/src/models/message_list.rs +++ b/src/models/message_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MessageList { /// Total number of messages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of messages. #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_messages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MessageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mfa_challenge.rs b/src/models/mfa_challenge.rs index cee280b..ce8a91a 100644 --- a/src/models/mfa_challenge.rs +++ b/src/models/mfa_challenge.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallenge { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl MfaChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_challenge_secret.rs b/src/models/mfa_challenge_secret.rs index 42a9c6e..e21b3ae 100644 --- a/src/models/mfa_challenge_secret.rs +++ b/src/models/mfa_challenge_secret.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallengeSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Challenge code to be delivered to the end user through a custom channel. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl MfaChallengeSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_factors.rs b/src/models/mfa_factors.rs index 14b1ebf..6415f45 100644 --- a/src/models/mfa_factors.rs +++ b/src/models/mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaFactors { /// Can TOTP be used for MFA challenge for this account. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Can phone (SMS) be used for MFA challenge for this account. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Can email be used for MFA challenge for this account. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Can recovery code be used for MFA challenge for this account. #[serde(rename = "recoveryCode")] + #[serde(default = "default_recovery_code")] pub recovery_code: bool, /// Can custom factor be used for MFA challenge for this account. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_totp() -> bool { + false +} + +fn default_phone() -> bool { + false +} + +fn default_email() -> bool { + false +} + +fn default_recovery_code() -> bool { + false +} + +fn default_custom() -> bool { + false +} + impl MfaFactors { /// Get totp pub fn totp(&self) -> &bool { diff --git a/src/models/mfa_recovery_codes.rs b/src/models/mfa_recovery_codes.rs index 44f77a3..c9089ef 100644 --- a/src/models/mfa_recovery_codes.rs +++ b/src/models/mfa_recovery_codes.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct MfaRecoveryCodes { /// Recovery codes. #[serde(rename = "recoveryCodes")] + #[serde(default = "default_recovery_codes")] pub recovery_codes: Vec, } +fn default_recovery_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MfaRecoveryCodes { /// Get recovery_codes pub fn recovery_codes(&self) -> &Vec { diff --git a/src/models/mfa_type.rs b/src/models/mfa_type.rs index 7809d95..69e7a79 100644 --- a/src/models/mfa_type.rs +++ b/src/models/mfa_type.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MfaType { /// Secret token used for TOTP factor. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// URI for authenticator apps. #[serde(rename = "uri")] + #[serde(default = "default_uri")] pub uri: String, } +fn default_secret() -> String { + "".to_string() +} + +fn default_uri() -> String { + "".to_string() +} + impl MfaType { /// Get secret pub fn secret(&self) -> &String { diff --git a/src/models/mock_number.rs b/src/models/mock_number.rs index 1d8ea85..0a7244c 100644 --- a/src/models/mock_number.rs +++ b/src/models/mock_number.rs @@ -9,18 +9,38 @@ pub struct MockNumber { /// Mock phone number for testing phone authentication. Useful for testing /// phone authentication without sending an SMS. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: String, /// Mock OTP for the number. #[serde(rename = "otp")] + #[serde(default = "default_otp")] pub otp: String, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_number() -> String { + "".to_string() +} + +fn default_otp() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl MockNumber { /// Get number pub fn number(&self) -> &String { diff --git a/src/models/mock_number_list.rs b/src/models/mock_number_list.rs index b4d7f7f..44de93f 100644 --- a/src/models/mock_number_list.rs +++ b/src/models/mock_number_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MockNumberList { /// Total number of mockNumbers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of mockNumbers. #[serde(rename = "mockNumbers")] + #[serde(default = "default_mock_numbers")] pub mock_numbers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_mock_numbers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MockNumberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mod.rs b/src/models/mod.rs index 8c4e935..1eb0426 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -22,8 +22,6 @@ pub mod session_list; pub use session_list::SessionList; pub mod identity_list; pub use identity_list::IdentityList; -pub mod log_list; -pub use log_list::LogList; pub mod file_list; pub use file_list::FileList; pub mod bucket_list; @@ -196,8 +194,6 @@ pub mod document; pub use document::Document; pub mod presence; pub use presence::Presence; -pub mod log; -pub use log::Log; pub mod user; pub use user::User; pub mod algo_md5; @@ -268,8 +264,6 @@ pub mod key; pub use key::Key; pub mod ephemeral_key; pub use ephemeral_key::EphemeralKey; -pub mod dev_key; -pub use dev_key::DevKey; pub mod mock_number; pub use mock_number::MockNumber; pub mod o_auth2_github; @@ -396,6 +390,14 @@ pub mod policy_mfa_factors; pub use policy_mfa_factors::PolicyMfaFactors; pub mod policy_passkey; pub use policy_passkey::PolicyPasskey; +pub mod policy_deny_aliased_email; +pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; +pub mod policy_deny_disposable_email; +pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; +pub mod policy_deny_free_email; +pub use policy_deny_free_email::PolicyDenyFreeEmail; +pub mod policy_deny_corporate_email; +pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod platform_web; pub use platform_web::PlatformWeb; pub mod platform_apple; @@ -534,14 +536,6 @@ pub mod dedicated_database_pitr_windows; pub use dedicated_database_pitr_windows::DedicatedDatabasePITRWindows; pub mod backup_policy; pub use backup_policy::BackupPolicy; -pub mod policy_deny_aliased_email; -pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; -pub mod policy_deny_disposable_email; -pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; -pub mod policy_deny_free_email; -pub use policy_deny_free_email::PolicyDenyFreeEmail; -pub mod policy_deny_corporate_email; -pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod dedicated_database_pooler; pub use dedicated_database_pooler::DedicatedDatabasePooler; pub mod postgres_extension; @@ -556,8 +550,6 @@ pub mod dedicated_database_specification; pub use dedicated_database_specification::DedicatedDatabaseSpecification; pub mod dedicated_database_specification_list; pub use dedicated_database_specification_list::DedicatedDatabaseSpecificationList; -pub mod dedicated_database_specification_pricing; -pub use dedicated_database_specification_pricing::DedicatedDatabaseSpecificationPricing; pub mod database_status_connections; pub use database_status_connections::DatabaseStatusConnections; pub mod database_status_replica; @@ -669,7 +661,6 @@ impl Model for ColumnIndexList {} impl Model for UserList {} impl Model for SessionList {} impl Model for IdentityList {} -impl Model for LogList {} impl Model for FileList {} impl Model for BucketList {} impl Model for ResourceTokenList {} @@ -756,7 +747,6 @@ impl Model for ColumnIndex {} impl Model for Row {} impl Model for Document {} impl Model for Presence {} -impl Model for Log {} impl Model for User {} impl Model for AlgoMd5 {} impl Model for AlgoSha {} @@ -792,7 +782,6 @@ impl Model for ProjectProtocol {} impl Model for Webhook {} impl Model for Key {} impl Model for EphemeralKey {} -impl Model for DevKey {} impl Model for MockNumber {} impl Model for OAuth2Github {} impl Model for OAuth2Discord {} @@ -856,6 +845,10 @@ impl Model for PolicyUserLimit {} impl Model for PolicyMembershipPrivacy {} impl Model for PolicyMfaFactors {} impl Model for PolicyPasskey {} +impl Model for PolicyDenyAliasedEmail {} +impl Model for PolicyDenyDisposableEmail {} +impl Model for PolicyDenyFreeEmail {} +impl Model for PolicyDenyCorporateEmail {} impl Model for PlatformWeb {} impl Model for PlatformApple {} impl Model for PlatformAndroid {} @@ -925,10 +918,6 @@ impl Model for ProxyInvalidation {} impl Model for Organization {} impl Model for DedicatedDatabasePITRWindows {} impl Model for BackupPolicy {} -impl Model for PolicyDenyAliasedEmail {} -impl Model for PolicyDenyDisposableEmail {} -impl Model for PolicyDenyFreeEmail {} -impl Model for PolicyDenyCorporateEmail {} impl Model for DedicatedDatabasePooler {} impl Model for PostgresExtension {} impl Model for Program {} @@ -936,7 +925,6 @@ impl Model for BackupRestoration {} impl Model for DedicatedDatabaseRestorationList {} impl Model for DedicatedDatabaseSpecification {} impl Model for DedicatedDatabaseSpecificationList {} -impl Model for DedicatedDatabaseSpecificationPricing {} impl Model for DatabaseStatusConnections {} impl Model for DatabaseStatusReplica {} impl Model for DatabaseStatusVolume {} diff --git a/src/models/o_auth2_amazon.rs b/src/models/o_auth2_amazon.rs index c2359b9..6e79642 100644 --- a/src/models/o_auth2_amazon.rs +++ b/src/models/o_auth2_amazon.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Amazon { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Amazon OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Amazon OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Amazon { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_apple.rs b/src/models/o_auth2_apple.rs index 5022915..3b357f7 100644 --- a/src/models/o_auth2_apple.rs +++ b/src/models/o_auth2_apple.rs @@ -8,34 +8,72 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Apple { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Apple OAuth2 service ID. #[serde(rename = "serviceId")] + #[serde(default = "default_service_id")] pub service_id: String, /// Apple OAuth2 key ID. #[serde(rename = "keyId")] + #[serde(default = "default_key_id")] pub key_id: String, /// Apple OAuth2 team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Apple OAuth2 .p8 private key file contents. The secret key wrapped by the /// PEM markers is 200 characters long. #[serde(rename = "p8File")] + #[serde(default = "default_p8_file")] pub p8_file: String, /// Native Sign in with Apple is active and can be used to create sessions from /// an ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// App bundle IDs accepted as ID token audiences for native Sign in with /// Apple, next to the Services ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_service_id() -> String { + "".to_string() +} + +fn default_key_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_p8_file() -> String { + "".to_string() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Apple { @@ -69,26 +107,14 @@ impl OAuth2Apple { &self.p8_file } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -105,6 +131,8 @@ mod tests { let _ = _model.key_id(); let _ = _model.team_id(); let _ = _model.p8_file(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_appwrite.rs b/src/models/o_auth2_appwrite.rs index 4ca0449..54ce0c8 100644 --- a/src/models/o_auth2_appwrite.rs +++ b/src/models/o_auth2_appwrite.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Appwrite { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Appwrite OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Appwrite OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Appwrite { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_auth0.rs b/src/models/o_auth2_auth0.rs index 12a3426..c974616 100644 --- a/src/models/o_auth2_auth0.rs +++ b/src/models/o_auth2_auth0.rs @@ -8,25 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Auth0 { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Auth0 OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Auth0 OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Auth0 OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Auth0 OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Auth0 { /// Get id pub fn id(&self) -> &String { @@ -48,15 +77,9 @@ impl OAuth2Auth0 { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get endpoint @@ -76,6 +99,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.endpoint(); } diff --git a/src/models/o_auth2_authentik.rs b/src/models/o_auth2_authentik.rs index da60963..8a4735b 100644 --- a/src/models/o_auth2_authentik.rs +++ b/src/models/o_auth2_authentik.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Authentik { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Authentik OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Authentik OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Authentik OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Authentik { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_autodesk.rs b/src/models/o_auth2_autodesk.rs index a487d8a..2f30585 100644 --- a/src/models/o_auth2_autodesk.rs +++ b/src/models/o_auth2_autodesk.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Autodesk { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Autodesk OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Autodesk OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Autodesk { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitbucket.rs b/src/models/o_auth2_bitbucket.rs index cfe595b..1694254 100644 --- a/src/models/o_auth2_bitbucket.rs +++ b/src/models/o_auth2_bitbucket.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitbucket { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitbucket OAuth2 key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Bitbucket OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + impl OAuth2Bitbucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitly.rs b/src/models/o_auth2_bitly.rs index 15a0774..1f0d383 100644 --- a/src/models/o_auth2_bitly.rs +++ b/src/models/o_auth2_bitly.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitly { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitly OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Bitly OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Bitly { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_box.rs b/src/models/o_auth2_box.rs index 83959c8..c2fefe6 100644 --- a/src/models/o_auth2_box.rs +++ b/src/models/o_auth2_box.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Box { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Box OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Box OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Box { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_cloudflare.rs b/src/models/o_auth2_cloudflare.rs index 3f6703f..6c977c2 100644 --- a/src/models/o_auth2_cloudflare.rs +++ b/src/models/o_auth2_cloudflare.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Cloudflare { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Cloudflare OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Cloudflare OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Cloudflare { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dailymotion.rs b/src/models/o_auth2_dailymotion.rs index b94e6bc..795a455 100644 --- a/src/models/o_auth2_dailymotion.rs +++ b/src/models/o_auth2_dailymotion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dailymotion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dailymotion OAuth2 API key. #[serde(rename = "apiKey")] + #[serde(default = "default_api_key")] pub api_key: String, /// Dailymotion OAuth2 API secret. #[serde(rename = "apiSecret")] + #[serde(default = "default_api_secret")] pub api_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_api_key() -> String { + "".to_string() +} + +fn default_api_secret() -> String { + "".to_string() +} + impl OAuth2Dailymotion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_discord.rs b/src/models/o_auth2_discord.rs index 91a601b..9c0c58d 100644 --- a/src/models/o_auth2_discord.rs +++ b/src/models/o_auth2_discord.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Discord { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Discord OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Discord OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Discord OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Discord { @@ -45,15 +69,9 @@ impl OAuth2Discord { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_disqus.rs b/src/models/o_auth2_disqus.rs index 467e840..957c4f6 100644 --- a/src/models/o_auth2_disqus.rs +++ b/src/models/o_auth2_disqus.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Disqus { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Disqus OAuth2 public key. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: String, /// Disqus OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_public_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Disqus { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dropbox.rs b/src/models/o_auth2_dropbox.rs index d566903..9160dbd 100644 --- a/src/models/o_auth2_dropbox.rs +++ b/src/models/o_auth2_dropbox.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dropbox { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dropbox OAuth2 app key. #[serde(rename = "appKey")] + #[serde(default = "default_app_key")] pub app_key: String, /// Dropbox OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_key() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Dropbox { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_etsy.rs b/src/models/o_auth2_etsy.rs index cf6bab9..a0158a0 100644 --- a/src/models/o_auth2_etsy.rs +++ b/src/models/o_auth2_etsy.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Etsy { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Etsy OAuth2 keystring. #[serde(rename = "keyString")] + #[serde(default = "default_key_string")] pub key_string: String, /// Etsy OAuth2 shared secret. #[serde(rename = "sharedSecret")] + #[serde(default = "default_shared_secret")] pub shared_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key_string() -> String { + "".to_string() +} + +fn default_shared_secret() -> String { + "".to_string() +} + impl OAuth2Etsy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_facebook.rs b/src/models/o_auth2_facebook.rs index c8c3bd9..7cabbef 100644 --- a/src/models/o_auth2_facebook.rs +++ b/src/models/o_auth2_facebook.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Facebook { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Facebook OAuth2 app ID. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Facebook OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Facebook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_figma.rs b/src/models/o_auth2_figma.rs index 0ef3e3b..99c241c 100644 --- a/src/models/o_auth2_figma.rs +++ b/src/models/o_auth2_figma.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Figma { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Figma OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Figma OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Figma { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_fusion_auth.rs b/src/models/o_auth2_fusion_auth.rs index 2222752..a9a7122 100644 --- a/src/models/o_auth2_fusion_auth.rs +++ b/src/models/o_auth2_fusion_auth.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2FusionAuth { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// FusionAuth OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// FusionAuth OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// FusionAuth OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2FusionAuth { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_github.rs b/src/models/o_auth2_github.rs index 1be7953..684abde 100644 --- a/src/models/o_auth2_github.rs +++ b/src/models/o_auth2_github.rs @@ -8,21 +8,45 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Github { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App /// ID and client ID are available. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// GitHub OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// GitHub OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Github { @@ -46,15 +70,9 @@ impl OAuth2Github { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -69,6 +87,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_gitlab.rs b/src/models/o_auth2_gitlab.rs index 8444d1b..fa76ce7 100644 --- a/src/models/o_auth2_gitlab.rs +++ b/src/models/o_auth2_gitlab.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Gitlab { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitLab OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// GitLab OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted /// instances. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Gitlab { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_google.rs b/src/models/o_auth2_google.rs index ece34e2..e9261a9 100644 --- a/src/models/o_auth2_google.rs +++ b/src/models/o_auth2_google.rs @@ -8,30 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Google { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Google OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Google OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Google OAuth2 prompt values. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: Vec, /// Native Google sign-in is active and can be used to create sessions from an /// ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// Additional OAuth2 client IDs accepted as ID token audiences for native /// sign-in, next to the client ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!(["consent"])).unwrap() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Google { @@ -60,26 +93,14 @@ impl OAuth2Google { &self.prompt } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -95,6 +116,8 @@ mod tests { let _ = _model.client_id(); let _ = _model.client_secret(); let _ = _model.prompt(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_hugging_face.rs b/src/models/o_auth2_hugging_face.rs index 6259543..43b9831 100644 --- a/src/models/o_auth2_hugging_face.rs +++ b/src/models/o_auth2_hugging_face.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2HuggingFace { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Hugging Face OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Hugging Face OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2HuggingFace { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_keycloak.rs b/src/models/o_auth2_keycloak.rs index 1586924..b5fd439 100644 --- a/src/models/o_auth2_keycloak.rs +++ b/src/models/o_auth2_keycloak.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Keycloak { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Keycloak OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Keycloak OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Keycloak OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, /// Keycloak OAuth2 realm name. #[serde(rename = "realmName")] + #[serde(default = "default_realm_name")] pub realm_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + +fn default_realm_name() -> String { + "".to_string() +} + impl OAuth2Keycloak { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_kick.rs b/src/models/o_auth2_kick.rs index d3f982f..12376b0 100644 --- a/src/models/o_auth2_kick.rs +++ b/src/models/o_auth2_kick.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Kick { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Kick OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Kick OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Kick { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_linkedin.rs b/src/models/o_auth2_linkedin.rs index 1c1077e..e76011f 100644 --- a/src/models/o_auth2_linkedin.rs +++ b/src/models/o_auth2_linkedin.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Linkedin { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// LinkedIn OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// LinkedIn OAuth2 primary client secret. #[serde(rename = "primaryClientSecret")] + #[serde(default = "default_primary_client_secret")] pub primary_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_primary_client_secret() -> String { + "".to_string() +} + impl OAuth2Linkedin { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_microsoft.rs b/src/models/o_auth2_microsoft.rs index 3a2535b..3aab893 100644 --- a/src/models/o_auth2_microsoft.rs +++ b/src/models/o_auth2_microsoft.rs @@ -8,26 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Microsoft { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Microsoft OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// Microsoft OAuth2 application secret. #[serde(rename = "applicationSecret")] + #[serde(default = "default_application_secret")] pub application_secret: String, /// Microsoft OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Microsoft Entra ID tenant identifier. Use 'common', 'organizations', /// 'consumers' or a specific tenant ID. #[serde(rename = "tenant")] + #[serde(default = "default_tenant")] pub tenant: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_application_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tenant() -> String { + "".to_string() +} + impl OAuth2Microsoft { /// Get id pub fn id(&self) -> &String { @@ -49,15 +78,9 @@ impl OAuth2Microsoft { &self.application_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get tenant @@ -77,6 +100,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.application_id(); let _ = _model.application_secret(); + let _ = _model.prompt(); let _ = _model.tenant(); } diff --git a/src/models/o_auth2_notion.rs b/src/models/o_auth2_notion.rs index c42807b..bb32958 100644 --- a/src/models/o_auth2_notion.rs +++ b/src/models/o_auth2_notion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Notion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Notion OAuth2 client ID. #[serde(rename = "oauthClientId")] + #[serde(default = "default_oauth_client_id")] pub oauth_client_id: String, /// Notion OAuth2 client secret. #[serde(rename = "oauthClientSecret")] + #[serde(default = "default_oauth_client_secret")] pub oauth_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth_client_id() -> String { + "".to_string() +} + +fn default_oauth_client_secret() -> String { + "".to_string() +} + impl OAuth2Notion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_oidc.rs b/src/models/o_auth2_oidc.rs index 010281d..aa2df42 100644 --- a/src/models/o_auth2_oidc.rs +++ b/src/models/o_auth2_oidc.rs @@ -8,33 +8,42 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Oidc { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OpenID Connect OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// OpenID Connect OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, + /// OpenID Connect prompt values controlling the authentication and consent + /// screens. + #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] + pub prompt: Vec, /// OpenID Connect well-known configuration URL. When set, authorization, /// token, and user info endpoints can be discovered automatically. #[serde(rename = "wellKnownURL")] + #[serde(default = "default_well_known_url")] pub well_known_url: String, /// OpenID Connect authorization endpoint URL. #[serde(rename = "authorizationURL")] + #[serde(default = "default_authorization_url")] pub authorization_url: String, /// OpenID Connect token endpoint URL. #[serde(rename = "tokenURL")] + #[serde(default = "default_token_url")] pub token_url: String, /// OpenID Connect user info endpoint URL. #[serde(rename = "userInfoURL")] + #[serde(default = "default_user_info_url")] pub user_info_url: String, - /// OpenID Connect prompt values controlling the authentication and consent - /// screens. - #[serde(rename = "prompt")] - pub prompt: Vec, /// Maximum authentication age in seconds. When set, the user must have /// authenticated within this many seconds. #[serde(rename = "maxAge")] @@ -42,6 +51,42 @@ pub struct OAuth2Oidc { pub max_age: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_well_known_url() -> String { + "".to_string() +} + +fn default_authorization_url() -> String { + "".to_string() +} + +fn default_token_url() -> String { + "".to_string() +} + +fn default_user_info_url() -> String { + "".to_string() +} + impl OAuth2Oidc { /// Get id pub fn id(&self) -> &String { @@ -63,6 +108,11 @@ impl OAuth2Oidc { &self.client_secret } + /// Get prompt + pub fn prompt(&self) -> &Vec { + &self.prompt + } + /// Get well_known_url pub fn well_known_url(&self) -> &String { &self.well_known_url @@ -83,11 +133,6 @@ impl OAuth2Oidc { &self.user_info_url } - /// Get prompt - pub fn prompt(&self) -> &Vec { - &self.prompt - } - /// Set max_age pub fn set_max_age(mut self, max_age: i64) -> Self { self.max_age = Some(max_age); @@ -111,11 +156,11 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.well_known_url(); let _ = _model.authorization_url(); let _ = _model.token_url(); let _ = _model.user_info_url(); - let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_okta.rs b/src/models/o_auth2_okta.rs index e8fdf00..be8da90 100644 --- a/src/models/o_auth2_okta.rs +++ b/src/models/o_auth2_okta.rs @@ -8,28 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Okta { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Okta OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Okta OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Okta OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Okta OAuth2 domain. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Okta OAuth2 authorization server ID. #[serde(rename = "authorizationServerId")] + #[serde(default = "default_authorization_server_id")] pub authorization_server_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_authorization_server_id() -> String { + "".to_string() +} + impl OAuth2Okta { /// Get id pub fn id(&self) -> &String { @@ -51,15 +85,9 @@ impl OAuth2Okta { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get domain @@ -84,6 +112,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.domain(); let _ = _model.authorization_server_id(); } diff --git a/src/models/o_auth2_paypal.rs b/src/models/o_auth2_paypal.rs index 41539e5..50ff622 100644 --- a/src/models/o_auth2_paypal.rs +++ b/src/models/o_auth2_paypal.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Paypal { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// PayPal OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// PayPal OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Paypal { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_podio.rs b/src/models/o_auth2_podio.rs index 87bb74a..cd87360 100644 --- a/src/models/o_auth2_podio.rs +++ b/src/models/o_auth2_podio.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Podio { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Podio OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Podio OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Podio { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_provider_list.rs b/src/models/o_auth2_provider_list.rs index a3354d1..510881c 100644 --- a/src/models/o_auth2_provider_list.rs +++ b/src/models/o_auth2_provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2ProviderList { /// Total number of OAuth2 providers in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of OAuth2 providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl OAuth2ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/o_auth2_resend.rs b/src/models/o_auth2_resend.rs index 1658315..773278e 100644 --- a/src/models/o_auth2_resend.rs +++ b/src/models/o_auth2_resend.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Resend { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Resend OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Resend OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Resend { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_salesforce.rs b/src/models/o_auth2_salesforce.rs index 4565047..addaba3 100644 --- a/src/models/o_auth2_salesforce.rs +++ b/src/models/o_auth2_salesforce.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Salesforce { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Salesforce OAuth2 consumer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// Salesforce OAuth2 consumer secret. #[serde(rename = "customerSecret")] + #[serde(default = "default_customer_secret")] pub customer_secret: String, /// Salesforce OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_customer_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Salesforce { @@ -45,15 +69,9 @@ impl OAuth2Salesforce { &self.customer_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.customer_key(); let _ = _model.customer_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_slack.rs b/src/models/o_auth2_slack.rs index 3045596..1563a50 100644 --- a/src/models/o_auth2_slack.rs +++ b/src/models/o_auth2_slack.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Slack { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Slack OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Slack OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Slack { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_spotify.rs b/src/models/o_auth2_spotify.rs index 00572b9..00d8ad3 100644 --- a/src/models/o_auth2_spotify.rs +++ b/src/models/o_auth2_spotify.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Spotify { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Spotify OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Spotify OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Spotify { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_stripe.rs b/src/models/o_auth2_stripe.rs index 5b1565d..8c7a9c0 100644 --- a/src/models/o_auth2_stripe.rs +++ b/src/models/o_auth2_stripe.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Stripe { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Stripe OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Stripe OAuth2 API secret key. #[serde(rename = "apiSecretKey")] + #[serde(default = "default_api_secret_key")] pub api_secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_api_secret_key() -> String { + "".to_string() +} + impl OAuth2Stripe { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_tradeshift.rs b/src/models/o_auth2_tradeshift.rs index ba79a82..70533ca 100644 --- a/src/models/o_auth2_tradeshift.rs +++ b/src/models/o_auth2_tradeshift.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Tradeshift { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Tradeshift OAuth2 client ID. #[serde(rename = "oauth2ClientId")] + #[serde(default = "default_oauth2_client_id")] pub oauth2_client_id: String, /// Tradeshift OAuth2 client secret. #[serde(rename = "oauth2ClientSecret")] + #[serde(default = "default_oauth2_client_secret")] pub oauth2_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth2_client_id() -> String { + "".to_string() +} + +fn default_oauth2_client_secret() -> String { + "".to_string() +} + impl OAuth2Tradeshift { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_twitch.rs b/src/models/o_auth2_twitch.rs index e0550f7..d3f246a 100644 --- a/src/models/o_auth2_twitch.rs +++ b/src/models/o_auth2_twitch.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Twitch { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Twitch OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Twitch OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Twitch { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_word_press.rs b/src/models/o_auth2_word_press.rs index a340ebc..52fb61b 100644 --- a/src/models/o_auth2_word_press.rs +++ b/src/models/o_auth2_word_press.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2WordPress { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// WordPress OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// WordPress OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2WordPress { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_x.rs b/src/models/o_auth2_x.rs index c3c4f83..8161a8e 100644 --- a/src/models/o_auth2_x.rs +++ b/src/models/o_auth2_x.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2X { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// X OAuth2 customer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// X OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2X { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yahoo.rs b/src/models/o_auth2_yahoo.rs index 18c69b1..d69e55e 100644 --- a/src/models/o_auth2_yahoo.rs +++ b/src/models/o_auth2_yahoo.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yahoo { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yahoo OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yahoo OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yahoo { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yandex.rs b/src/models/o_auth2_yandex.rs index 9db7bc6..d7e59dd 100644 --- a/src/models/o_auth2_yandex.rs +++ b/src/models/o_auth2_yandex.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yandex { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yandex OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yandex OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yandex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_zoho.rs b/src/models/o_auth2_zoho.rs index 58cef47..8477a96 100644 --- a/src/models/o_auth2_zoho.rs +++ b/src/models/o_auth2_zoho.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoho { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoho OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoho OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Zoho OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Zoho { @@ -45,15 +69,9 @@ impl OAuth2Zoho { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_zoom.rs b/src/models/o_auth2_zoom.rs index e0047c3..4c44b8d 100644 --- a/src/models/o_auth2_zoom.rs +++ b/src/models/o_auth2_zoom.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoom { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoom OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoom OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Zoom { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_approve.rs b/src/models/oauth2_approve.rs index a946f11..ac5ce43 100644 --- a/src/models/oauth2_approve.rs +++ b/src/models/oauth2_approve.rs @@ -10,9 +10,14 @@ pub struct Oauth2Approve { /// carrying the authorization `code` and/or `id_token` along with the original /// `state`. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Approve { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_authorize.rs b/src/models/oauth2_authorize.rs index 5063ed7..89f1f92 100644 --- a/src/models/oauth2_authorize.rs +++ b/src/models/oauth2_authorize.rs @@ -10,13 +10,23 @@ pub struct Oauth2Authorize { /// the approve or reject endpoint. Empty when a redirect URL is returned /// instead. #[serde(rename = "grantId")] + #[serde(default = "default_grant_id")] pub grant_id: String, /// URL the end user should be redirected to when the flow can complete without /// consent. Empty when consent is still required. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_grant_id() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Authorize { /// Get grant_id pub fn grant_id(&self) -> &String { diff --git a/src/models/oauth2_consent.rs b/src/models/oauth2_consent.rs index 995d15b..a6e4b9e 100644 --- a/src/models/oauth2_consent.rs +++ b/src/models/oauth2_consent.rs @@ -8,40 +8,90 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Consent { /// Consent ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Consent creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Consent update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the consent belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the consent was given to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the consent was given to. /// Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes the user consented to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators the user consented to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details the user consented to, as a JSON string. Each entry /// has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Consent expiration time in ISO 8601 format. Empty when the consent has no /// token-bound expiry yet. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Consent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_list.rs b/src/models/oauth2_consent_list.rs index 3982df2..b019afe 100644 --- a/src/models/oauth2_consent_list.rs +++ b/src/models/oauth2_consent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentList { /// Total number of consents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of consents. #[serde(rename = "consents")] + #[serde(default = "default_consents")] pub consents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_consents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_consent_token.rs b/src/models/oauth2_consent_token.rs index 4d2f43f..776ba73 100644 --- a/src/models/oauth2_consent_token.rs +++ b/src/models/oauth2_consent_token.rs @@ -8,44 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentToken { /// Token family ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Token update date in ISO 8601 format. Refreshing the token family updates /// this. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the consent the token family was issued under. #[serde(rename = "consentId")] + #[serde(default = "default_consent_id")] pub consent_id: String, /// ID of the user the token family belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the token family was issued to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the token family was issued /// to. Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes granted on the token family. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators granted on the token family. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details granted on the token family, as a JSON string. Each /// entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Expiration time of the current access token of this family in ISO 8601 /// format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_consent_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2ConsentToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_token_list.rs b/src/models/oauth2_consent_token_list.rs index 9f5f5ad..906b8e2 100644 --- a/src/models/oauth2_consent_token_list.rs +++ b/src/models/oauth2_consent_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_device_authorization.rs b/src/models/oauth2_device_authorization.rs index 80feee2..f0bef4d 100644 --- a/src/models/oauth2_device_authorization.rs +++ b/src/models/oauth2_device_authorization.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2DeviceAuthorization { /// Device verification code used by the client to poll the token endpoint. #[serde(rename = "device_code")] + #[serde(default = "default_device_code")] pub device_code: String, /// Short code the end user enters on the verification page. #[serde(rename = "user_code")] + #[serde(default = "default_user_code")] pub user_code: String, /// URL where the end user enters the user code. #[serde(rename = "verification_uri")] + #[serde(default = "default_verification_uri")] pub verification_uri: String, /// Verification URL with the user code prefilled as a query parameter. #[serde(rename = "verification_uri_complete")] + #[serde(default = "default_verification_uri_complete")] pub verification_uri_complete: String, /// Lifetime of the device code and user code in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// Minimum polling interval for the token endpoint in seconds. #[serde(rename = "interval")] + #[serde(default = "default_interval")] pub interval: i64, } +fn default_device_code() -> String { + "".to_string() +} + +fn default_user_code() -> String { + "".to_string() +} + +fn default_verification_uri() -> String { + "".to_string() +} + +fn default_verification_uri_complete() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_interval() -> i64 { + 0 +} + impl Oauth2DeviceAuthorization { /// Get device_code pub fn device_code(&self) -> &String { diff --git a/src/models/oauth2_grant.rs b/src/models/oauth2_grant.rs index 16d716d..b6e37b0 100644 --- a/src/models/oauth2_grant.rs +++ b/src/models/oauth2_grant.rs @@ -8,45 +8,105 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Grant { /// Grant ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Grant creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Grant update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the grant belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the OAuth2 client (app) the grant was requested for. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Requested OAuth2 scopes the user is being asked to consent to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Requested RFC 8707 resource indicators the user is being asked to consent /// to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Requested authorization_details the user is being asked to consent to, as a /// JSON string. Each entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// OIDC prompt directive the consent screen should honor. Space-separated list /// of: login, consent, select_account. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: String, /// Redirect URI the user will be sent to after the flow completes. #[serde(rename = "redirectUri")] + #[serde(default = "default_redirect_uri")] pub redirect_uri: String, /// Unix timestamp of when the user last authenticated. #[serde(rename = "authTime")] + #[serde(default = "default_auth_time")] pub auth_time: i64, /// Grant expiration time in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_prompt() -> String { + "".to_string() +} + +fn default_redirect_uri() -> String { + "".to_string() +} + +fn default_auth_time() -> i64 { + 0 +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Grant { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization.rs b/src/models/oauth2_organization.rs index b2c20fc..ff1bf2b 100644 --- a/src/models/oauth2_organization.rs +++ b/src/models/oauth2_organization.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Organization { /// Organization ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, } +fn default_id() -> String { + "".to_string() +} + impl Oauth2Organization { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization_list.rs b/src/models/oauth2_organization_list.rs index 1309964..0188ebd 100644 --- a/src/models/oauth2_organization_list.rs +++ b/src/models/oauth2_organization_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2OrganizationList { /// Total number of organizations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of organizations. #[serde(rename = "organizations")] + #[serde(default = "default_organizations")] pub organizations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_organizations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2OrganizationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_par.rs b/src/models/oauth2_par.rs index f1d779e..09e366f 100644 --- a/src/models/oauth2_par.rs +++ b/src/models/oauth2_par.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2PAR { /// Authorization request handle to pass to the authorize endpoint. #[serde(rename = "request_uri")] + #[serde(default = "default_request_uri")] pub request_uri: String, /// Lifetime of the authorization request handle in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, } +fn default_request_uri() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + impl Oauth2PAR { /// Get request_uri pub fn request_uri(&self) -> &String { diff --git a/src/models/oauth2_project.rs b/src/models/oauth2_project.rs index 5af4e85..78ea717 100644 --- a/src/models/oauth2_project.rs +++ b/src/models/oauth2_project.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Region ID the project is deployed in. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// API endpoint of the region the project is deployed in. Empty when the /// region has no public hostname configured. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl Oauth2Project { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_project_list.rs b/src/models/oauth2_project_list.rs index 2e849fb..3e8b16c 100644 --- a/src/models/oauth2_project_list.rs +++ b/src/models/oauth2_project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_reject.rs b/src/models/oauth2_reject.rs index 5daab49..7051bb4 100644 --- a/src/models/oauth2_reject.rs +++ b/src/models/oauth2_reject.rs @@ -9,9 +9,14 @@ pub struct Oauth2Reject { /// URL the end user should be redirected to after the grant is rejected, /// carrying an `access_denied` error. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Reject { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_token.rs b/src/models/oauth2_token.rs index 37b8552..9c647fb 100644 --- a/src/models/oauth2_token.rs +++ b/src/models/oauth2_token.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Token { /// OAuth2 access token. #[serde(rename = "access_token")] + #[serde(default = "default_access_token")] pub access_token: String, /// OAuth2 token type. #[serde(rename = "token_type")] + #[serde(default = "default_token_type")] pub token_type: String, /// Access token lifetime in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// OAuth2 refresh token. #[serde(rename = "refresh_token")] + #[serde(default = "default_refresh_token")] pub refresh_token: String, /// Space-separated scopes granted to the access token. #[serde(rename = "scope")] + #[serde(default = "default_scope")] pub scope: String, /// Granted RFC 9396 authorization details as a JSON string. #[serde(rename = "authorization_details")] @@ -31,6 +36,26 @@ pub struct Oauth2Token { pub id_token: Option, } +fn default_access_token() -> String { + "".to_string() +} + +fn default_token_type() -> String { + "Bearer".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_refresh_token() -> String { + "".to_string() +} + +fn default_scope() -> String { + "".to_string() +} + impl Oauth2Token { /// Get access_token pub fn access_token(&self) -> &String { diff --git a/src/models/organization.rs b/src/models/organization.rs index f7ec61d..82eeded 100644 --- a/src/models/organization.rs +++ b/src/models/organization.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Organization { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] @@ -30,44 +35,55 @@ pub struct Organization { pub billing_budget: Option, /// Project budget limit #[serde(rename = "budgetAlerts")] + #[serde(default = "default_budget_alerts")] pub budget_alerts: Vec, /// Organization's billing plan ID. #[serde(rename = "billingPlan")] + #[serde(default = "default_billing_plan")] pub billing_plan: String, /// Organization's billing plan ID. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, /// Organization's billing plan. #[serde(rename = "billingPlanDetails")] pub billing_plan_details: crate::models::BillingPlan, /// Billing email set for the organization. #[serde(rename = "billingEmail")] + #[serde(default = "default_billing_email")] pub billing_email: String, /// Billing cycle start date. #[serde(rename = "billingStartDate")] - pub billing_start_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_start_date: Option, /// Current invoice cycle start date. #[serde(rename = "billingCurrentInvoiceDate")] - pub billing_current_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_current_invoice_date: Option, /// Next invoice cycle start date. #[serde(rename = "billingNextInvoiceDate")] - pub billing_next_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_next_invoice_date: Option, /// Start date of trial. #[serde(rename = "billingTrialStartDate")] #[serde(skip_serializing_if = "Option::is_none")] pub billing_trial_start_date: Option, /// Number of trial days. #[serde(rename = "billingTrialDays")] - pub billing_trial_days: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_trial_days: Option, /// Current active aggregation id. #[serde(rename = "billingAggregationId")] - pub billing_aggregation_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_aggregation_id: Option, /// Current active aggregation id. #[serde(rename = "billingInvoiceId")] - pub billing_invoice_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_invoice_id: Option, /// Default payment method. #[serde(rename = "paymentMethodId")] - pub payment_method_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_id: Option, /// Default payment method. #[serde(rename = "billingAddressId")] #[serde(skip_serializing_if = "Option::is_none")] @@ -78,6 +94,7 @@ pub struct Organization { pub backup_payment_method_id: Option, /// Team status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Remarks on team status. #[serde(rename = "remarks")] @@ -117,15 +134,70 @@ pub struct Organization { pub billing_tax_id: Option, /// Marked for deletion #[serde(rename = "markedForDeletion")] + #[serde(default = "default_marked_for_deletion")] pub marked_for_deletion: bool, /// Product with which the organization is associated (appwrite or imagine) #[serde(rename = "platform")] + #[serde(default = "default_platform")] pub platform: String, /// Selected projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + +fn default_budget_alerts() -> Vec { + serde_json::from_value(serde_json::json!([75])).unwrap() +} + +fn default_billing_plan() -> String { + "tier-0".to_string() +} + +fn default_billing_plan_id() -> String { + "tier-0".to_string() +} + +fn default_billing_email() -> String { + "".to_string() +} + +fn default_status() -> String { + "draft".to_string() +} + +fn default_marked_for_deletion() -> bool { + false +} + +fn default_platform() -> String { + "appwrite".to_string() +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Organization { /// Get id pub fn id(&self) -> &String { @@ -193,19 +265,40 @@ impl Organization { &self.billing_email } + /// Set billing_start_date + pub fn set_billing_start_date(mut self, billing_start_date: String) -> Self { + self.billing_start_date = Some(billing_start_date); + self + } + /// Get billing_start_date - pub fn billing_start_date(&self) -> &String { - &self.billing_start_date + pub fn billing_start_date(&self) -> Option<&String> { + self.billing_start_date.as_ref() + } + + /// Set billing_current_invoice_date + pub fn set_billing_current_invoice_date( + mut self, + billing_current_invoice_date: String, + ) -> Self { + self.billing_current_invoice_date = Some(billing_current_invoice_date); + self } /// Get billing_current_invoice_date - pub fn billing_current_invoice_date(&self) -> &String { - &self.billing_current_invoice_date + pub fn billing_current_invoice_date(&self) -> Option<&String> { + self.billing_current_invoice_date.as_ref() + } + + /// Set billing_next_invoice_date + pub fn set_billing_next_invoice_date(mut self, billing_next_invoice_date: String) -> Self { + self.billing_next_invoice_date = Some(billing_next_invoice_date); + self } /// Get billing_next_invoice_date - pub fn billing_next_invoice_date(&self) -> &String { - &self.billing_next_invoice_date + pub fn billing_next_invoice_date(&self) -> Option<&String> { + self.billing_next_invoice_date.as_ref() } /// Set billing_trial_start_date @@ -219,24 +312,48 @@ impl Organization { self.billing_trial_start_date.as_ref() } + /// Set billing_trial_days + pub fn set_billing_trial_days(mut self, billing_trial_days: i64) -> Self { + self.billing_trial_days = Some(billing_trial_days); + self + } + /// Get billing_trial_days - pub fn billing_trial_days(&self) -> &i64 { - &self.billing_trial_days + pub fn billing_trial_days(&self) -> Option<&i64> { + self.billing_trial_days.as_ref() + } + + /// Set billing_aggregation_id + pub fn set_billing_aggregation_id(mut self, billing_aggregation_id: String) -> Self { + self.billing_aggregation_id = Some(billing_aggregation_id); + self } /// Get billing_aggregation_id - pub fn billing_aggregation_id(&self) -> &String { - &self.billing_aggregation_id + pub fn billing_aggregation_id(&self) -> Option<&String> { + self.billing_aggregation_id.as_ref() + } + + /// Set billing_invoice_id + pub fn set_billing_invoice_id(mut self, billing_invoice_id: String) -> Self { + self.billing_invoice_id = Some(billing_invoice_id); + self } /// Get billing_invoice_id - pub fn billing_invoice_id(&self) -> &String { - &self.billing_invoice_id + pub fn billing_invoice_id(&self) -> Option<&String> { + self.billing_invoice_id.as_ref() + } + + /// Set payment_method_id + pub fn set_payment_method_id(mut self, payment_method_id: String) -> Self { + self.payment_method_id = Some(payment_method_id); + self } /// Get payment_method_id - pub fn payment_method_id(&self) -> &String { - &self.payment_method_id + pub fn payment_method_id(&self) -> Option<&String> { + self.payment_method_id.as_ref() } /// Set billing_address_id @@ -402,13 +519,6 @@ mod tests { let _ = _model.billing_plan_id(); let _ = _model.billing_plan_details(); let _ = _model.billing_email(); - let _ = _model.billing_start_date(); - let _ = _model.billing_current_invoice_date(); - let _ = _model.billing_next_invoice_date(); - let _ = _model.billing_trial_days(); - let _ = _model.billing_aggregation_id(); - let _ = _model.billing_invoice_id(); - let _ = _model.payment_method_id(); let _ = _model.status(); let _ = _model.marked_for_deletion(); let _ = _model.platform(); diff --git a/src/models/passkey.rs b/src/models/passkey.rs index 0685af4..9f9afb4 100644 --- a/src/models/passkey.rs +++ b/src/models/passkey.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct Passkey { /// Passkey ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Passkey creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Passkey update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Passkey name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Most recent sign-in with this passkey in ISO 8601 format. Empty until the /// passkey is used to sign in. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl Passkey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_challenge.rs b/src/models/passkey_challenge.rs index 8ecada5..a0cffe5 100644 --- a/src/models/passkey_challenge.rs +++ b/src/models/passkey_challenge.rs @@ -9,23 +9,48 @@ pub struct PasskeyChallenge { /// Challenge ID. When signing in, pass it back with the credential to receive /// a token. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Challenge creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// ID of the passkey being registered. Empty for sign-in challenges. #[serde(rename = "passkeyId")] + #[serde(default = "default_passkey_id")] pub passkey_id: String, /// Challenge expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// WebAuthn options in JSON form. Pass them to /// `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or /// `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: serde_json::Value, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_passkey_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_public_key() -> serde_json::Value { + serde_json::json!({}) +} + impl PasskeyChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_list.rs b/src/models/passkey_list.rs index 8b9e05e..5f9a82c 100644 --- a/src/models/passkey_list.rs +++ b/src/models/passkey_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PasskeyList { /// Total number of passkeys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of passkeys. #[serde(rename = "passkeys")] + #[serde(default = "default_passkeys")] pub passkeys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_passkeys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PasskeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/phone.rs b/src/models/phone.rs index 2d6a27c..f06631b 100644 --- a/src/models/phone.rs +++ b/src/models/phone.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Phone { /// Phone code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + impl Phone { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/phone_list.rs b/src/models/phone_list.rs index 53939ae..b17138c 100644 --- a/src/models/phone_list.rs +++ b/src/models/phone_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PhoneList { /// Total number of phones that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of phones. #[serde(rename = "phones")] + #[serde(default = "default_phones")] pub phones: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_phones() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PhoneList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_android.rs b/src/models/platform_android.rs index 7f35a47..28a4ac1 100644 --- a/src/models/platform_android.rs +++ b/src/models/platform_android.rs @@ -8,27 +8,56 @@ use serde::{Deserialize, Serialize}; pub struct PlatformAndroid { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Android application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// SHA-256 fingerprints of the certificates the app is signed with. Passkeys /// created in the app are accepted when its signature matches one. #[serde(rename = "fingerprints")] - #[serde(skip_serializing_if = "Option::is_none")] - pub fingerprints: Option>, + #[serde(default = "default_fingerprints")] + pub fingerprints: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_fingerprints() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl PlatformAndroid { @@ -62,15 +91,9 @@ impl PlatformAndroid { &self.application_id } - /// Set fingerprints - pub fn set_fingerprints(mut self, fingerprints: Vec) -> Self { - self.fingerprints = Some(fingerprints); - self - } - /// Get fingerprints - pub fn fingerprints(&self) -> Option<&Vec> { - self.fingerprints.as_ref() + pub fn fingerprints(&self) -> &Vec { + &self.fingerprints } } @@ -87,6 +110,7 @@ mod tests { let _ = _model.name(); let _ = _model.r#type(); let _ = _model.application_id(); + let _ = _model.fingerprints(); } #[test] diff --git a/src/models/platform_apple.rs b/src/models/platform_apple.rs index c157274..fd57555 100644 --- a/src/models/platform_apple.rs +++ b/src/models/platform_apple.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformApple { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Apple bundle identifier. #[serde(rename = "bundleIdentifier")] + #[serde(default = "default_bundle_identifier")] pub bundle_identifier: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_bundle_identifier() -> String { + "".to_string() +} + impl PlatformApple { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_linux.rs b/src/models/platform_linux.rs index d305b51..db7b998 100644 --- a/src/models/platform_linux.rs +++ b/src/models/platform_linux.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformLinux { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Linux package name. #[serde(rename = "packageName")] + #[serde(default = "default_package_name")] pub package_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_name() -> String { + "".to_string() +} + impl PlatformLinux { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_list.rs b/src/models/platform_list.rs index 523fc50..5caaee7 100644 --- a/src/models/platform_list.rs +++ b/src/models/platform_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PlatformList { /// Total number of platforms in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of platforms. #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_platforms() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PlatformList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_web.rs b/src/models/platform_web.rs index 5daea92..a35b4c5 100644 --- a/src/models/platform_web.rs +++ b/src/models/platform_web.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWeb { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Web app hostname. Empty string for other platforms. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + impl PlatformWeb { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_windows.rs b/src/models/platform_windows.rs index da5c08f..52d9c7a 100644 --- a/src/models/platform_windows.rs +++ b/src/models/platform_windows.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWindows { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Windows package identifier name. #[serde(rename = "packageIdentifierName")] + #[serde(default = "default_package_identifier_name")] pub package_identifier_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_identifier_name() -> String { + "".to_string() +} + impl PlatformWindows { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_aliased_email.rs b/src/models/policy_deny_aliased_email.rs index c7327b0..bca4bde 100644 --- a/src/models/policy_deny_aliased_email.rs +++ b/src/models/policy_deny_aliased_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyAliasedEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny aliased email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyAliasedEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_corporate_email.rs b/src/models/policy_deny_corporate_email.rs index 8b271b9..b90e444 100644 --- a/src/models/policy_deny_corporate_email.rs +++ b/src/models/policy_deny_corporate_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyCorporateEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny non-corporate email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyCorporateEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_disposable_email.rs b/src/models/policy_deny_disposable_email.rs index 029a4fe..3cfb4ec 100644 --- a/src/models/policy_deny_disposable_email.rs +++ b/src/models/policy_deny_disposable_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyDisposableEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny disposable email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyDisposableEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_free_email.rs b/src/models/policy_deny_free_email.rs index 6038f66..5c1b61d 100644 --- a/src/models/policy_deny_free_email.rs +++ b/src/models/policy_deny_free_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyFreeEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny free email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyFreeEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_list.rs b/src/models/policy_list.rs index 559b319..cec5f0b 100644 --- a/src/models/policy_list.rs +++ b/src/models/policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyList { /// Total number of policies in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/policy_membership_privacy.rs b/src/models/policy_membership_privacy.rs index 8b17314..c42cc90 100644 --- a/src/models/policy_membership_privacy.rs +++ b/src/models/policy_membership_privacy.rs @@ -8,27 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMembershipPrivacy { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether user ID is visible in memberships. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: bool, /// Whether user email is visible in memberships. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: bool, /// Whether user phone is visible in memberships. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: bool, /// Whether user name is visible in memberships. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: bool, /// Whether user MFA status is visible in memberships. #[serde(rename = "userMFA")] + #[serde(default = "default_user_mfa")] pub user_mfa: bool, /// Whether user last access time is visible in memberships. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_user_id() -> bool { + false +} + +fn default_user_email() -> bool { + false +} + +fn default_user_phone() -> bool { + false +} + +fn default_user_name() -> bool { + false +} + +fn default_user_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> bool { + false +} + impl PolicyMembershipPrivacy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_mfa_factors.rs b/src/models/policy_mfa_factors.rs index a6634b6..5d6a1f3 100644 --- a/src/models/policy_mfa_factors.rs +++ b/src/models/policy_mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMfaFactors { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether TOTP can be used to complete an MFA challenge. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Whether email can be used to complete an MFA challenge. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Whether phone (SMS) can be used to complete an MFA challenge. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Whether the custom factor can be used to complete an MFA challenge. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_totp() -> bool { + true +} + +fn default_email() -> bool { + true +} + +fn default_phone() -> bool { + true +} + +fn default_custom() -> bool { + false +} + impl PolicyMfaFactors { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_passkey.rs b/src/models/policy_passkey.rs index 3306d5e..e556cbc 100644 --- a/src/models/policy_passkey.rs +++ b/src/models/policy_passkey.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasskey { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Relying party ID passkeys are bound to. Empty until configured. #[serde(rename = "rpId")] + #[serde(default = "default_rp_id")] pub rp_id: String, /// Web origins passkeys work on, from the project's platforms on the relying /// party ID and a localhost web platform. Read-only. #[serde(rename = "origins")] + #[serde(default = "default_origins")] pub origins: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_rp_id() -> String { + "".to_string() +} + +fn default_origins() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyPasskey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_dictionary.rs b/src/models/policy_password_dictionary.rs index e14d27b..2d9857d 100644 --- a/src/models/policy_password_dictionary.rs +++ b/src/models/policy_password_dictionary.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordDictionary { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password dictionary policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordDictionary { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_history.rs b/src/models/policy_password_history.rs index 6f00db0..e356b25 100644 --- a/src/models/policy_password_history.rs +++ b/src/models/policy_password_history.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordHistory { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Password history length. A value of 0 means the policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyPasswordHistory { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_personal_data.rs b/src/models/policy_password_personal_data.rs index 6fee0df..9b19000 100644 --- a/src/models/policy_password_personal_data.rs +++ b/src/models/policy_password_personal_data.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordPersonalData { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password personal data policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordPersonalData { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_strength.rs b/src/models/policy_password_strength.rs index fa3b56a..08ff7bb 100644 --- a/src/models/policy_password_strength.rs +++ b/src/models/policy_password_strength.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordStrength { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Minimum password length required for user passwords. #[serde(rename = "min")] + #[serde(default = "default_min")] pub min: i64, /// Whether passwords must include at least one uppercase letter. #[serde(rename = "uppercase")] + #[serde(default = "default_uppercase")] pub uppercase: bool, /// Whether passwords must include at least one lowercase letter. #[serde(rename = "lowercase")] + #[serde(default = "default_lowercase")] pub lowercase: bool, /// Whether passwords must include at least one number. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: bool, /// Whether passwords must include at least one symbol. #[serde(rename = "symbols")] + #[serde(default = "default_symbols")] pub symbols: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_min() -> i64 { + 8 +} + +fn default_uppercase() -> bool { + false +} + +fn default_lowercase() -> bool { + false +} + +fn default_number() -> bool { + false +} + +fn default_symbols() -> bool { + false +} + impl PolicyPasswordStrength { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_alert.rs b/src/models/policy_session_alert.rs index 3689003..84ebba2 100644 --- a/src/models/policy_session_alert.rs +++ b/src/models/policy_session_alert.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionAlert { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session alert policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicySessionAlert { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_duration.rs b/src/models/policy_session_duration.rs index 4cf1a79..93e96dc 100644 --- a/src/models/policy_session_duration.rs +++ b/src/models/policy_session_duration.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionDuration { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session duration in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_duration() -> i64 { + 31536000 +} + impl PolicySessionDuration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_invalidation.rs b/src/models/policy_session_invalidation.rs index 07846c9..f63d898 100644 --- a/src/models/policy_session_invalidation.rs +++ b/src/models/policy_session_invalidation.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionInvalidation { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session invalidation policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + impl PolicySessionInvalidation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_limit.rs b/src/models/policy_session_limit.rs index 86f066f..c6b02b8 100644 --- a/src/models/policy_session_limit.rs +++ b/src/models/policy_session_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of sessions allowed per user. A value of 0 means the policy /// is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicySessionLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_user_limit.rs b/src/models/policy_user_limit.rs index 4515afd..84b0359 100644 --- a/src/models/policy_user_limit.rs +++ b/src/models/policy_user_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicyUserLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of users allowed in the project. A value of 0 means the /// policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyUserLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/postgres_extension.rs b/src/models/postgres_extension.rs index 6fa2b95..8e2cb31 100644 --- a/src/models/postgres_extension.rs +++ b/src/models/postgres_extension.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct PostgresExtension { /// Extension key used with CREATE EXTENSION. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Human-readable extension name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Short description of what the extension provides. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Category the extension belongs to. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + impl PostgresExtension { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/presence.rs b/src/models/presence.rs index 5ed34d4..845310e 100644 --- a/src/models/presence.rs +++ b/src/models/presence.rs @@ -8,19 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct Presence { /// Presence ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Presence creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Presence update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Presence permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Presence status. #[serde(rename = "status")] @@ -28,6 +33,7 @@ pub struct Presence { pub status: Option, /// Presence source. #[serde(rename = "source")] + #[serde(default = "default_source")] pub source: String, /// Presence expiry date in ISO 8601 format. #[serde(rename = "expiresAt")] @@ -39,6 +45,30 @@ pub struct Presence { pub metadata: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_source() -> String { + "".to_string() +} + impl Presence { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/presence_list.rs b/src/models/presence_list.rs index 0257bf7..6a006b2 100644 --- a/src/models/presence_list.rs +++ b/src/models/presence_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PresenceList { /// Total number of presences that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of presences. #[serde(rename = "presences")] + #[serde(default = "default_presences")] pub presences: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_presences() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PresenceList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/program.rs b/src/models/program.rs index 588d509..06eedf7 100644 --- a/src/models/program.rs +++ b/src/models/program.rs @@ -8,33 +8,78 @@ use serde::{Deserialize, Serialize}; pub struct Program { /// Program ID #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Program title #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Program description #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Program tag for highlighting on console #[serde(rename = "tag")] + #[serde(default = "default_tag")] pub tag: String, /// Program icon for highlighting on console #[serde(rename = "icon")] + #[serde(default = "default_icon")] pub icon: String, /// URL for more information on this program #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Whether this program is active #[serde(rename = "active")] + #[serde(default = "default_active")] pub active: bool, /// Whether this program is external #[serde(rename = "external")] + #[serde(default = "default_external")] pub external: bool, /// Billing plan ID that this is program is associated with. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_tag() -> String { + "".to_string() +} + +fn default_icon() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_active() -> bool { + true +} + +fn default_external() -> bool { + true +} + +fn default_billing_plan_id() -> String { + "".to_string() +} + impl Program { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/project.rs b/src/models/project.rs index 78a7fc7..962b910 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -8,87 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Project creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Project update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Project team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Project region #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, - /// Deprecated since 1.9.5: List of dev keys. - #[serde(rename = "devKeys")] - pub dev_keys: Vec, /// Status for custom SMTP #[serde(rename = "smtpEnabled")] + #[serde(default = "default_smtp_enabled")] pub smtp_enabled: bool, /// SMTP sender name #[serde(rename = "smtpSenderName")] + #[serde(default = "default_smtp_sender_name")] pub smtp_sender_name: String, /// SMTP sender email #[serde(rename = "smtpSenderEmail")] + #[serde(default = "default_smtp_sender_email")] pub smtp_sender_email: String, /// SMTP reply to name #[serde(rename = "smtpReplyToName")] + #[serde(default = "default_smtp_reply_to_name")] pub smtp_reply_to_name: String, /// SMTP reply to email #[serde(rename = "smtpReplyToEmail")] + #[serde(default = "default_smtp_reply_to_email")] pub smtp_reply_to_email: String, /// SMTP server host name #[serde(rename = "smtpHost")] + #[serde(default = "default_smtp_host")] pub smtp_host: String, /// SMTP server port #[serde(rename = "smtpPort")] + #[serde(default = "default_smtp_port")] pub smtp_port: i64, /// SMTP server username #[serde(rename = "smtpUsername")] + #[serde(default = "default_smtp_username")] pub smtp_username: String, /// SMTP server password. This property is write-only and always returned /// empty. #[serde(rename = "smtpPassword")] + #[serde(default = "default_smtp_password")] pub smtp_password: String, /// SMTP server secure protocol #[serde(rename = "smtpSecure")] + #[serde(default = "default_smtp_secure")] pub smtp_secure: String, /// Number of times the ping was received for this project. #[serde(rename = "pingCount")] + #[serde(default = "default_ping_count")] pub ping_count: i64, /// Last ping datetime in ISO 8601 format. #[serde(rename = "pingedAt")] + #[serde(default = "default_pinged_at")] pub pinged_at: String, /// Labels for the project. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Project status #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Stage progress (completed or skipped) with timestamps and actor types, /// keyed by stage id. #[serde(rename = "onboarding")] + #[serde(default = "default_onboarding")] pub onboarding: serde_json::Value, /// List of auth methods. #[serde(rename = "authMethods")] + #[serde(default = "default_auth_methods")] pub auth_methods: Vec, /// List of services. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// List of protocols. #[serde(rename = "protocols")] + #[serde(default = "default_protocols")] pub protocols: Vec, /// Project blocks information #[serde(rename = "blocks")] + #[serde(default = "default_blocks")] pub blocks: Vec, /// Last time the project was accessed via console. Used with plan's /// projectInactivityDays to determine if project is paused. #[serde(rename = "consoleAccessedAt")] + #[serde(default = "default_console_accessed_at")] pub console_accessed_at: String, /// Whether WAF enforcement is enabled for the project. #[serde(rename = "wafEnabled")] @@ -192,6 +215,110 @@ pub struct Project { pub o_auth2_server_discovery_url: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "fra".to_string() +} + +fn default_smtp_enabled() -> bool { + false +} + +fn default_smtp_sender_name() -> String { + "".to_string() +} + +fn default_smtp_sender_email() -> String { + "".to_string() +} + +fn default_smtp_reply_to_name() -> String { + "".to_string() +} + +fn default_smtp_reply_to_email() -> String { + "".to_string() +} + +fn default_smtp_host() -> String { + "".to_string() +} + +fn default_smtp_port() -> i64 { + 0 +} + +fn default_smtp_username() -> String { + "".to_string() +} + +fn default_smtp_password() -> String { + "".to_string() +} + +fn default_smtp_secure() -> String { + "".to_string() +} + +fn default_ping_count() -> i64 { + 0 +} + +fn default_pinged_at() -> String { + "".to_string() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_onboarding() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_auth_methods() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_protocols() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_blocks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_console_accessed_at() -> String { + "".to_string() +} + impl Project { /// Get id pub fn id(&self) -> &String { @@ -223,11 +350,6 @@ impl Project { &self.region } - /// Get dev_keys - pub fn dev_keys(&self) -> &Vec { - &self.dev_keys - } - /// Get smtp_enabled pub fn smtp_enabled(&self) -> &bool { &self.smtp_enabled @@ -634,7 +756,6 @@ mod tests { let _ = _model.name(); let _ = _model.team_id(); let _ = _model.region(); - let _ = _model.dev_keys(); let _ = _model.smtp_enabled(); let _ = _model.smtp_sender_name(); let _ = _model.smtp_sender_email(); diff --git a/src/models/project_auth_method.rs b/src/models/project_auth_method.rs index e8428f1..37f1ef8 100644 --- a/src/models/project_auth_method.rs +++ b/src/models/project_auth_method.rs @@ -11,9 +11,14 @@ pub struct ProjectAuthMethod { pub id: crate::enums::ProjectAuthMethodId, /// Auth method status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectAuthMethod { /// Get id pub fn id(&self) -> &crate::enums::ProjectAuthMethodId { diff --git a/src/models/project_list.rs b/src/models/project_list.rs index 9bcda60..83f9fdc 100644 --- a/src/models/project_list.rs +++ b/src/models/project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/project_protocol.rs b/src/models/project_protocol.rs index a8bd9e1..82cf49e 100644 --- a/src/models/project_protocol.rs +++ b/src/models/project_protocol.rs @@ -11,9 +11,14 @@ pub struct ProjectProtocol { pub id: crate::enums::ProjectProtocolId, /// Protocol status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectProtocol { /// Get id pub fn id(&self) -> &crate::enums::ProjectProtocolId { diff --git a/src/models/project_service.rs b/src/models/project_service.rs index 4d94d38..7601ae4 100644 --- a/src/models/project_service.rs +++ b/src/models/project_service.rs @@ -11,9 +11,14 @@ pub struct ProjectService { pub id: crate::enums::ProjectServiceId, /// Service status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectService { /// Get id pub fn id(&self) -> &crate::enums::ProjectServiceId { diff --git a/src/models/provider.rs b/src/models/provider.rs index 6da6a12..0730ec8 100644 --- a/src/models/provider.rs +++ b/src/models/provider.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Provider { /// Provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Provider creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Provider update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name for the provider instance. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// The name of the provider service. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Is provider enabled? #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Type of provider. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Provider credentials. #[serde(rename = "credentials")] + #[serde(default = "default_credentials")] pub credentials: serde_json::Value, /// Provider options. #[serde(rename = "options")] @@ -36,6 +44,38 @@ pub struct Provider { pub options: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "".to_string() +} + +fn default_credentials() -> serde_json::Value { + serde_json::json!({}) +} + impl Provider { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/provider_list.rs b/src/models/provider_list.rs index 3d9c5c9..8d6e077 100644 --- a/src/models/provider_list.rs +++ b/src/models/provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProviderList { /// Total number of providers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/proxy_invalidation.rs b/src/models/proxy_invalidation.rs index eaec944..575f927 100644 --- a/src/models/proxy_invalidation.rs +++ b/src/models/proxy_invalidation.rs @@ -8,19 +8,39 @@ use serde::{Deserialize, Serialize}; pub struct ProxyInvalidation { /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Invalidation type. Possible values are "tag", "path", or "all". #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Invalidated reference. Depending on type this is a cache tag name, a URL /// path, or empty when type is all. #[serde(rename = "reference")] + #[serde(default = "default_reference")] pub reference: String, /// Invalidation status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, } +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_reference() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl ProxyInvalidation { /// Get domain pub fn domain(&self) -> &String { diff --git a/src/models/proxy_rule.rs b/src/models/proxy_rule.rs index 1082f77..41571e0 100644 --- a/src/models/proxy_rule.rs +++ b/src/models/proxy_rule.rs @@ -8,58 +8,122 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRule { /// Rule ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Rule creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Rule update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Action definition for the rule. Possible values are "api", "deployment", or /// "redirect" #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Defines how the rule was created. Possible values are "manual" or /// "deployment" #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// URL to redirect to. Used if type is "redirect" #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, /// Status code to apply during redirect. Used if type is "redirect" #[serde(rename = "redirectStatusCode")] + #[serde(default = "default_redirect_status_code")] pub redirect_status_code: i64, /// ID of deployment. Used if type is "deployment" #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, - /// Type of deployment. Possible values are "function", "site". Used if rule's - /// type is "deployment". + /// Type of deployment resource: function, site, or dedicatedDatabase. #[serde(rename = "deploymentResourceType")] #[serde(skip_serializing_if = "Option::is_none")] pub deployment_resource_type: Option, /// ID of deployment's resource (site or function ID). Used if type is /// "deployment" #[serde(rename = "deploymentResourceId")] + #[serde(default = "default_deployment_resource_id")] pub deployment_resource_id: String, /// Name of Git branch that updates rule. Used if type is "deployment" #[serde(rename = "deploymentVcsProviderBranch")] + #[serde(default = "default_deployment_vcs_provider_branch")] pub deployment_vcs_provider_branch: String, /// Domain verification status. Possible values are "unverified", "verifying", /// "verified" #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::ProxyRuleStatus, /// Logs from rule verification or certificate generation. Certificate /// generation logs are prioritized if both are available. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Certificate auto-renewal date in ISO 8601 format. #[serde(rename = "renewAt")] pub renew_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + +fn default_redirect_status_code() -> i64 { + 301 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_resource_id() -> String { + "".to_string() +} + +fn default_deployment_vcs_provider_branch() -> String { + "".to_string() +} + +fn default_status() -> crate::enums::ProxyRuleStatus { + serde_json::from_value(serde_json::json!("unverified")).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + impl ProxyRule { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/proxy_rule_list.rs b/src/models/proxy_rule_list.rs index ddd137d..e6ac600 100644 --- a/src/models/proxy_rule_list.rs +++ b/src/models/proxy_rule_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRuleList { /// Total number of rules that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rules. #[serde(rename = "rules")] + #[serde(default = "default_rules")] pub rules: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rules() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProxyRuleList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/report.rs b/src/models/report.rs index 4f43770..f1992ae 100644 --- a/src/models/report.rs +++ b/src/models/report.rs @@ -8,38 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Report { /// Report ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Report creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Report update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the third-party app that submitted the report. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Analyzer that produced this report. e.g. lighthouse, audit, /// databaseAnalyzer. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Short, human-readable title for the report. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Markdown summary describing the report. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// Plural noun describing what the report analyzes, e.g. databases, sites, /// urls. #[serde(rename = "targetType")] + #[serde(default = "default_target_type")] pub target_type: String, /// Free-form target identifier (URL for lighthouse, resource ID for db). #[serde(rename = "target")] + #[serde(default = "default_target")] pub target: String, /// Categories covered by the report, e.g. performance, accessibility. #[serde(rename = "categories")] + #[serde(default = "default_categories")] pub categories: Vec, /// Insights nested under this report. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, /// Time the report was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -47,6 +58,50 @@ pub struct Report { pub analyzed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_target_type() -> String { + "".to_string() +} + +fn default_target() -> String { + "".to_string() +} + +fn default_categories() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Report { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/report_list.rs b/src/models/report_list.rs index 81b4995..4c1c5ca 100644 --- a/src/models/report_list.rs +++ b/src/models/report_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ReportList { /// Total number of reports that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of reports. #[serde(rename = "reports")] + #[serde(default = "default_reports")] pub reports: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_reports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ReportList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/resource_token.rs b/src/models/resource_token.rs index 2108383..4efceee 100644 --- a/src/models/resource_token.rs +++ b/src/models/resource_token.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct ResourceToken { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// JWT encoded string. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl ResourceToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/resource_token_list.rs b/src/models/resource_token_list.rs index af45953..de499c1 100644 --- a/src/models/resource_token_list.rs +++ b/src/models/resource_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ResourceTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ResourceTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/row.rs b/src/models/row.rs index 6c50624..308b438 100644 --- a/src/models/row.rs +++ b/src/models/row.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Row { /// Row ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Row sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Table ID. #[serde(rename = "$tableId")] + #[serde(default = "default_table_id")] pub table_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Row creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Row update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Row permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_table_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Row { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/row_list.rs b/src/models/row_list.rs index ff8047e..1ec0e23 100644 --- a/src/models/row_list.rs +++ b/src/models/row_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RowList { /// Total number of rows that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rows. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RowList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/runtime.rs b/src/models/runtime.rs index 71b88a9..d053cb1 100644 --- a/src/models/runtime.rs +++ b/src/models/runtime.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct Runtime { /// Runtime ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Parent runtime key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Runtime Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Runtime version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Base Docker image used to build the runtime. #[serde(rename = "base")] + #[serde(default = "default_base")] pub base: String, /// Image name of Docker Hub. #[serde(rename = "image")] + #[serde(default = "default_image")] pub image: String, /// Name of the logo image. #[serde(rename = "logo")] + #[serde(default = "default_logo")] pub logo: String, /// List of supported architectures. #[serde(rename = "supports")] + #[serde(default = "default_supports")] pub supports: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_base() -> String { + "".to_string() +} + +fn default_image() -> String { + "".to_string() +} + +fn default_logo() -> String { + "".to_string() +} + +fn default_supports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Runtime { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/runtime_list.rs b/src/models/runtime_list.rs index de7e84b..b45492d 100644 --- a/src/models/runtime_list.rs +++ b/src/models/runtime_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RuntimeList { /// Total number of runtimes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of runtimes. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RuntimeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/session.rs b/src/models/session.rs index 228fc31..3a775e0 100644 --- a/src/models/session.rs +++ b/src/models/session.rs @@ -8,97 +8,242 @@ use serde::{Deserialize, Serialize}; pub struct Session { /// Session ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Session update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Session expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Session Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Session Provider User ID. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Session Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Session Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// IP in use when the session was created. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Operating system code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). #[serde(rename = "osCode")] + #[serde(default = "default_os_code")] pub os_code: String, /// Operating system name. #[serde(rename = "osName")] + #[serde(default = "default_os_name")] pub os_name: String, /// Operating system version. #[serde(rename = "osVersion")] + #[serde(default = "default_os_version")] pub os_version: String, /// Client type. #[serde(rename = "clientType")] + #[serde(default = "default_client_type")] pub client_type: String, /// Client code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). #[serde(rename = "clientCode")] + #[serde(default = "default_client_code")] pub client_code: String, /// Client name. #[serde(rename = "clientName")] + #[serde(default = "default_client_name")] pub client_name: String, /// Client version. #[serde(rename = "clientVersion")] + #[serde(default = "default_client_version")] pub client_version: String, /// Client engine name. #[serde(rename = "clientEngine")] + #[serde(default = "default_client_engine")] pub client_engine: String, /// Client engine name. #[serde(rename = "clientEngineVersion")] + #[serde(default = "default_client_engine_version")] pub client_engine_version: String, /// Device name. #[serde(rename = "deviceName")] + #[serde(default = "default_device_name")] pub device_name: String, /// Device brand name. #[serde(rename = "deviceBrand")] + #[serde(default = "default_device_brand")] pub device_brand: String, /// Device model name. #[serde(rename = "deviceModel")] + #[serde(default = "default_device_model")] pub device_model: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, /// Returns true if this the current user session. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: bool, /// Returns a list of active session factors. #[serde(rename = "factors")] + #[serde(default = "default_factors")] pub factors: Vec, /// Secret used to authenticate the user. Only included if the request was made /// with an API key #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent date in ISO 8601 format when the session successfully passed /// MFA challenge. #[serde(rename = "mfaUpdatedAt")] + #[serde(default = "default_mfa_updated_at")] pub mfa_updated_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_os_code() -> String { + "".to_string() +} + +fn default_os_name() -> String { + "".to_string() +} + +fn default_os_version() -> String { + "".to_string() +} + +fn default_client_type() -> String { + "".to_string() +} + +fn default_client_code() -> String { + "".to_string() +} + +fn default_client_name() -> String { + "".to_string() +} + +fn default_client_version() -> String { + "".to_string() +} + +fn default_client_engine() -> String { + "".to_string() +} + +fn default_client_engine_version() -> String { + "".to_string() +} + +fn default_device_name() -> String { + "".to_string() +} + +fn default_device_brand() -> String { + "".to_string() +} + +fn default_device_model() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + +fn default_current() -> bool { + false +} + +fn default_factors() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_mfa_updated_at() -> String { + "".to_string() +} + impl Session { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/session_list.rs b/src/models/session_list.rs index 8e912c5..f74e7d3 100644 --- a/src/models/session_list.rs +++ b/src/models/session_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SessionList { /// Total number of sessions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sessions. #[serde(rename = "sessions")] + #[serde(default = "default_sessions")] pub sessions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sessions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SessionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/site.rs b/src/models/site.rs index 4cb6f80..a1f7723 100644 --- a/src/models/site.rs +++ b/src/models/site.rs @@ -8,112 +8,145 @@ use serde::{Deserialize, Serialize}; pub struct Site { /// Site ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Site creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Site update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Site name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Site enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the site deployed with the latest configuration? This is set to false if /// you've changed an environment variables, entrypoint, commands, or other /// settings that needs redeploy to be applied. When the value is false, /// redeploy the site to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, request logs will exclude logs and errors, and site /// responses will be slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Site framework. #[serde(rename = "framework")] + #[serde(default = "default_framework")] pub framework: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Site's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Screenshot of active deployment with light theme preference file ID. #[serde(rename = "deploymentScreenshotLight")] + #[serde(default = "default_deployment_screenshot_light")] pub deployment_screenshot_light: String, /// Screenshot of active deployment with dark theme preference file ID. #[serde(rename = "deploymentScreenshotDark")] + #[serde(default = "default_deployment_screenshot_dark")] pub deployment_screenshot_dark: String, /// Site's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Site variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Site request timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The install command used to install the site dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// The build command used to build the site. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Custom command to use when starting site runtime. #[serde(rename = "startCommand")] + #[serde(default = "default_start_command")] pub start_command: String, /// The directory where the site build output is located. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Site VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to site in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for SSR executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, /// Site build runtime. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// Site framework adapter. #[serde(rename = "adapter")] @@ -124,6 +157,138 @@ pub struct Site { pub fallback_file: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_framework() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_deployment_screenshot_light() -> String { + "".to_string() +} + +fn default_deployment_screenshot_dark() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_start_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + impl Site { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/site_list.rs b/src/models/site_list.rs index 1525368..ac1e2eb 100644 --- a/src/models/site_list.rs +++ b/src/models/site_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SiteList { /// Total number of sites that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sites. #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sites() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SiteList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/specification.rs b/src/models/specification.rs index 1cbb8a2..006eaf5 100644 --- a/src/models/specification.rs +++ b/src/models/specification.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Specification { /// Memory size in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Number of CPUs. #[serde(rename = "cpus")] + #[serde(default = "default_cpus")] pub cpus: f64, /// Is size enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Size slug. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, } +fn default_memory() -> i64 { + 0 +} + +fn default_cpus() -> f64 { + 0.0 +} + +fn default_enabled() -> bool { + false +} + +fn default_slug() -> String { + "".to_string() +} + impl Specification { /// Get memory pub fn memory(&self) -> &i64 { diff --git a/src/models/specification_list.rs b/src/models/specification_list.rs index de28440..887dc11 100644 --- a/src/models/specification_list.rs +++ b/src/models/specification_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SpecificationList { /// Total number of specifications that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SpecificationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/subscriber.rs b/src/models/subscriber.rs index 00b5d42..ed5a3b1 100644 --- a/src/models/subscriber.rs +++ b/src/models/subscriber.rs @@ -8,34 +8,74 @@ use serde::{Deserialize, Serialize}; pub struct Subscriber { /// Subscriber ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Subscriber creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Subscriber update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target ID. #[serde(rename = "targetId")] + #[serde(default = "default_target_id")] pub target_id: String, /// Target. #[serde(rename = "target")] pub target: crate::models::Target, /// Topic ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User Name. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// Topic ID. #[serde(rename = "topicId")] + #[serde(default = "default_topic_id")] pub topic_id: String, /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_target_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_topic_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + impl Subscriber { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/subscriber_list.rs b/src/models/subscriber_list.rs index 045c977..64636fe 100644 --- a/src/models/subscriber_list.rs +++ b/src/models/subscriber_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SubscriberList { /// Total number of subscribers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of subscribers. #[serde(rename = "subscribers")] + #[serde(default = "default_subscribers")] pub subscribers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_subscribers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SubscriberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/table.rs b/src/models/table.rs index 82cb1f0..1c33993 100644 --- a/src/models/table.rs +++ b/src/models/table.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Table { /// Table ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Table creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Table update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Table permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Table name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is /// inaccessible to users, but remains accessible to Server SDKs using API /// keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether row-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "rowSecurity")] + #[serde(default = "default_row_security")] pub row_security: bool, /// Table columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Table indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum row size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used row size in bytes based on defined columns. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_row_security() -> bool { + false +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Table { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/table_list.rs b/src/models/table_list.rs index 73748c1..53c23be 100644 --- a/src/models/table_list.rs +++ b/src/models/table_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TableList { /// Total number of tables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tables. #[serde(rename = "tables")] + #[serde(default = "default_tables")] pub tables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/target.rs b/src/models/target.rs index 79d2dc8..7bec4f4 100644 --- a/src/models/target.rs +++ b/src/models/target.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Target { /// Target ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Target creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Target update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Provider ID. #[serde(rename = "providerId")] @@ -28,15 +33,50 @@ pub struct Target { /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// The target identifier. #[serde(rename = "identifier")] + #[serde(default = "default_identifier")] pub identifier: String, /// Is the target expired. #[serde(rename = "expired")] + #[serde(default = "default_expired")] pub expired: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_identifier() -> String { + "".to_string() +} + +fn default_expired() -> bool { + false +} + impl Target { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/target_list.rs b/src/models/target_list.rs index a3edee5..0c7f169 100644 --- a/src/models/target_list.rs +++ b/src/models/target_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TargetList { /// Total number of targets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of targets. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TargetList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/team.rs b/src/models/team.rs index b951756..7da273c 100644 --- a/src/models/team.rs +++ b/src/models/team.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Team { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] pub prefs: crate::models::Preferences, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl Team { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/team_list.rs b/src/models/team_list.rs index d1df58e..f128b40 100644 --- a/src/models/team_list.rs +++ b/src/models/team_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TeamList { /// Total number of teams that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of teams. #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_teams() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TeamList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/token.rs b/src/models/token.rs index 89f96f4..903214a 100644 --- a/src/models/token.rs +++ b/src/models/token.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct Token { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. This will return an empty string unless the response is /// returned using an API key or as part of a webhook payload. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl Token { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/token_secret.rs b/src/models/token_secret.rs index 442416e..de2563e 100644 --- a/src/models/token_secret.rs +++ b/src/models/token_secret.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct TokenSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. Exchange it for a session with the create session /// endpoint. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl TokenSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic.rs b/src/models/topic.rs index 976d41b..ea701c4 100644 --- a/src/models/topic.rs +++ b/src/models/topic.rs @@ -8,39 +8,81 @@ use serde::{Deserialize, Serialize}; pub struct Topic { /// Topic ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Topic creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Topic update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name of the topic. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total count of email subscribers subscribed to the topic. #[serde(rename = "emailTotal")] + #[serde(default = "default_email_total")] pub email_total: i64, /// Total count of SMS subscribers subscribed to the topic. #[serde(rename = "smsTotal")] + #[serde(default = "default_sms_total")] pub sms_total: i64, /// Total count of push subscribers subscribed to the topic. #[serde(rename = "pushTotal")] + #[serde(default = "default_push_total")] pub push_total: i64, /// Subscribe permissions. #[serde(rename = "subscribe")] + #[serde(default = "default_subscribe")] pub subscribe: Vec, /// MQTT QoS for delivery on this topic. Null lets the subscriber choose their /// level. #[serde(rename = "qos")] #[serde(skip_serializing_if = "Option::is_none")] pub qos: Option, - /// Message retention in seconds for offline delivery. + /// Message retention in seconds for offline delivery. Null inherits the lowest + /// expiry of the project's enabled Appwrite providers, or the 7-day ledger + /// window if none sets one. #[serde(rename = "expiry")] #[serde(skip_serializing_if = "Option::is_none")] pub expiry: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_email_total() -> i64 { + 0 +} + +fn default_sms_total() -> i64 { + 0 +} + +fn default_push_total() -> i64 { + 0 +} + +fn default_subscribe() -> Vec { + serde_json::from_value(serde_json::json!(["users"])).unwrap() +} + impl Topic { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic_list.rs b/src/models/topic_list.rs index 824d84b..b7e128d 100644 --- a/src/models/topic_list.rs +++ b/src/models/topic_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TopicList { /// Total number of topics that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of topics. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TopicList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/transaction.rs b/src/models/transaction.rs index bb2272a..e034fe3 100644 --- a/src/models/transaction.rs +++ b/src/models/transaction.rs @@ -8,25 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct Transaction { /// Transaction ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Transaction creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Transaction update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Current status of the transaction. One of: pending, committing, committed, /// rolled_back, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of operations in the transaction. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: i64, /// Expiration time in ISO 8601 format. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_operations() -> i64 { + 0 +} + +fn default_expires_at() -> String { + "".to_string() +} + impl Transaction { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/transaction_list.rs b/src/models/transaction_list.rs index 29cab9e..6ebd9a0 100644 --- a/src/models/transaction_list.rs +++ b/src/models/transaction_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TransactionList { /// Total number of transactions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of transactions. #[serde(rename = "transactions")] + #[serde(default = "default_transactions")] pub transactions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_transactions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TransactionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/usage_billing_plan.rs b/src/models/usage_billing_plan.rs index ab2c459..ead81be 100644 --- a/src/models/usage_billing_plan.rs +++ b/src/models/usage_billing_plan.rs @@ -8,36 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct UsageBillingPlan { /// Bandwidth additional resources #[serde(rename = "bandwidth")] - pub bandwidth: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub bandwidth: Option, /// Executions additional resources #[serde(rename = "executions")] - pub executions: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub executions: Option, /// Member additional resources #[serde(rename = "member")] #[serde(skip_serializing_if = "Option::is_none")] pub member: Option, /// Realtime additional resources #[serde(rename = "realtime")] - pub realtime: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime: Option, /// Realtime messages additional resources #[serde(rename = "realtimeMessages")] - pub realtime_messages: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime_messages: Option, /// Realtime bandwidth additional resources #[serde(rename = "realtimeBandwidth")] #[serde(skip_serializing_if = "Option::is_none")] pub realtime_bandwidth: Option, /// Storage additional resources #[serde(rename = "storage")] - pub storage: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub storage: Option, /// User additional resources #[serde(rename = "users")] - pub users: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub users: Option, /// GBHour additional resources #[serde(rename = "GBHours")] - pub gb_hours: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub gb_hours: Option, /// Image transformation additional resources #[serde(rename = "imageTransformations")] - pub image_transformations: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub image_transformations: Option, /// Credits additional resources #[serde(rename = "credits")] #[serde(skip_serializing_if = "Option::is_none")] @@ -45,14 +53,26 @@ pub struct UsageBillingPlan { } impl UsageBillingPlan { + /// Set bandwidth + pub fn set_bandwidth(mut self, bandwidth: crate::models::AdditionalResource) -> Self { + self.bandwidth = Some(bandwidth); + self + } + /// Get bandwidth - pub fn bandwidth(&self) -> &crate::models::AdditionalResource { - &self.bandwidth + pub fn bandwidth(&self) -> Option<&crate::models::AdditionalResource> { + self.bandwidth.as_ref() + } + + /// Set executions + pub fn set_executions(mut self, executions: crate::models::AdditionalResource) -> Self { + self.executions = Some(executions); + self } /// Get executions - pub fn executions(&self) -> &crate::models::AdditionalResource { - &self.executions + pub fn executions(&self) -> Option<&crate::models::AdditionalResource> { + self.executions.as_ref() } /// Set member @@ -66,14 +86,29 @@ impl UsageBillingPlan { self.member.as_ref() } + /// Set realtime + pub fn set_realtime(mut self, realtime: crate::models::AdditionalResource) -> Self { + self.realtime = Some(realtime); + self + } + /// Get realtime - pub fn realtime(&self) -> &crate::models::AdditionalResource { - &self.realtime + pub fn realtime(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime.as_ref() + } + + /// Set realtime_messages + pub fn set_realtime_messages( + mut self, + realtime_messages: crate::models::AdditionalResource, + ) -> Self { + self.realtime_messages = Some(realtime_messages); + self } /// Get realtime_messages - pub fn realtime_messages(&self) -> &crate::models::AdditionalResource { - &self.realtime_messages + pub fn realtime_messages(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime_messages.as_ref() } /// Set realtime_bandwidth @@ -90,24 +125,51 @@ impl UsageBillingPlan { self.realtime_bandwidth.as_ref() } + /// Set storage + pub fn set_storage(mut self, storage: crate::models::AdditionalResource) -> Self { + self.storage = Some(storage); + self + } + /// Get storage - pub fn storage(&self) -> &crate::models::AdditionalResource { - &self.storage + pub fn storage(&self) -> Option<&crate::models::AdditionalResource> { + self.storage.as_ref() + } + + /// Set users + pub fn set_users(mut self, users: crate::models::AdditionalResource) -> Self { + self.users = Some(users); + self } /// Get users - pub fn users(&self) -> &crate::models::AdditionalResource { - &self.users + pub fn users(&self) -> Option<&crate::models::AdditionalResource> { + self.users.as_ref() + } + + /// Set gb_hours + pub fn set_gb_hours(mut self, gb_hours: crate::models::AdditionalResource) -> Self { + self.gb_hours = Some(gb_hours); + self } /// Get gb_hours - pub fn gb_hours(&self) -> &crate::models::AdditionalResource { - &self.gb_hours + pub fn gb_hours(&self) -> Option<&crate::models::AdditionalResource> { + self.gb_hours.as_ref() + } + + /// Set image_transformations + pub fn set_image_transformations( + mut self, + image_transformations: crate::models::AdditionalResource, + ) -> Self { + self.image_transformations = Some(image_transformations); + self } /// Get image_transformations - pub fn image_transformations(&self) -> &crate::models::AdditionalResource { - &self.image_transformations + pub fn image_transformations(&self) -> Option<&crate::models::AdditionalResource> { + self.image_transformations.as_ref() } /// Set credits @@ -129,14 +191,6 @@ mod tests { #[test] fn test_usage_billing_plan_creation() { let _model = ::default(); - let _ = _model.bandwidth(); - let _ = _model.executions(); - let _ = _model.realtime(); - let _ = _model.realtime_messages(); - let _ = _model.storage(); - let _ = _model.users(); - let _ = _model.gb_hours(); - let _ = _model.image_transformations(); } #[test] diff --git a/src/models/user.rs b/src/models/user.rs index d6e6d2e..9bcaa78 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct User { /// User ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// User creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Hashed user password. #[serde(rename = "password")] @@ -32,24 +36,31 @@ pub struct User { pub hash_options: Option, /// User registration date in ISO 8601 format. #[serde(rename = "registration")] + #[serde(default = "default_registration")] pub registration: String, /// User status. Pass `true` for enabled and `false` for disabled. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: bool, /// Labels for the user. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Password update time in ISO 8601 format. #[serde(rename = "passwordUpdate")] + #[serde(default = "default_password_update")] pub password_update: String, /// User email address. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: String, /// User phone number in E.164 format. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: String, /// Email verification status. #[serde(rename = "emailVerification")] + #[serde(default = "default_email_verification")] pub email_verification: bool, /// Canonical form of the user email address. #[serde(rename = "emailCanonical")] @@ -78,9 +89,11 @@ pub struct User { pub password_pwned: Option, /// Phone verification status. #[serde(rename = "phoneVerification")] + #[serde(default = "default_phone_verification")] pub phone_verification: bool, /// Multi factor authentication status. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// User preferences as a key-value object #[serde(rename = "prefs")] @@ -88,10 +101,12 @@ pub struct User { /// A user-owned message receiver. A single user may have multiple e.g. emails, /// phones, and a browser. Each target is registered with a single provider. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// Whether the user can impersonate other users. #[serde(rename = "impersonator")] @@ -106,6 +121,66 @@ pub struct User { pub impersonator_user_id: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_registration() -> String { + "".to_string() +} + +fn default_status() -> bool { + true +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_password_update() -> String { + "".to_string() +} + +fn default_email() -> String { + "".to_string() +} + +fn default_phone() -> String { + "".to_string() +} + +fn default_email_verification() -> bool { + false +} + +fn default_phone_verification() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl User { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/user_list.rs b/src/models/user_list.rs index a6e27f4..16c8f64 100644 --- a/src/models/user_list.rs +++ b/src/models/user_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct UserList { /// Total number of users that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of users. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl UserList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/variable.rs b/src/models/variable.rs index cadb289..b27a858 100644 --- a/src/models/variable.rs +++ b/src/models/variable.rs @@ -8,33 +8,73 @@ use serde::{Deserialize, Serialize}; pub struct Variable { /// Variable ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Variable key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Variable value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Variable secret flag. Secret variables can only be updated or deleted, but /// never read. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: bool, /// Service to which the variable belongs. Possible values are "project", /// "function" #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of resource to which the variable belongs. If resourceType is "project", /// it is empty. If resourceType is "function", it is ID of the function. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + +fn default_secret() -> bool { + false +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + impl Variable { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/variable_list.rs b/src/models/variable_list.rs index 9720690..3c3a8bf 100644 --- a/src/models/variable_list.rs +++ b/src/models/variable_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VariableList { /// Total number of variables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of variables. #[serde(rename = "variables")] + #[serde(default = "default_variables")] pub variables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_variables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VariableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/vectorsdb_collection.rs b/src/models/vectorsdb_collection.rs index f352907..38e0c83 100644 --- a/src/models/vectorsdb_collection.rs +++ b/src/models/vectorsdb_collection.rs @@ -8,49 +8,114 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, /// Embedding dimension. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + +fn default_dimension() -> i64 { + 0 +} + impl VectorsdbCollection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/vectorsdb_collection_list.rs b/src/models/vectorsdb_collection_list.rs index 719dfca..09c5647 100644 --- a/src/models/vectorsdb_collection_list.rs +++ b/src/models/vectorsdb_collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VectorsdbCollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/webhook.rs b/src/models/webhook.rs index 5e398a3..3875de3 100644 --- a/src/models/webhook.rs +++ b/src/models/webhook.rs @@ -8,46 +8,111 @@ use serde::{Deserialize, Serialize}; pub struct Webhook { /// Webhook ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Webhook creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Webhook update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Webhook name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Webhook URL endpoint. #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Webhook trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Indicates if SSL / TLS certificate verification is enabled. #[serde(rename = "tls")] + #[serde(default = "default_tls")] pub tls: bool, /// HTTP basic authentication username. #[serde(rename = "authUsername")] + #[serde(default = "default_auth_username")] pub auth_username: String, - /// HTTP basic authentication password. + /// HTTP basic authentication password. Write-only: always returned empty. #[serde(rename = "authPassword")] + #[serde(default = "default_auth_password")] pub auth_password: String, /// Signature key which can be used to validate incoming webhook payloads. Only /// returned on creation and secret rotation. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Indicates if this webhook is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Webhook error logs from the most recent failure. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Number of consecutive failed webhook attempts. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tls() -> bool { + true +} + +fn default_auth_username() -> String { + "".to_string() +} + +fn default_auth_password() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + impl Webhook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/webhook_list.rs b/src/models/webhook_list.rs index 29d04f7..d9602c4 100644 --- a/src/models/webhook_list.rs +++ b/src/models/webhook_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct WebhookList { /// Total number of webhooks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of webhooks. #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_webhooks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl WebhookList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/services/account.rs b/src/services/account.rs index 9313048..1db7444 100644 --- a/src/services/account.rs +++ b/src/services/account.rs @@ -105,9 +105,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -117,18 +127,25 @@ impl Account { /// Delete an OAuth2 consent by its unique ID. All token families issued under /// the consent are revoked, and the app must ask for consent again to regain /// access. - pub async fn delete_consent( - &self, - consent_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_consent(&self, consent_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -157,9 +174,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -177,10 +204,30 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -194,16 +241,36 @@ impl Account { &self, consent_id: impl Into, token_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -270,43 +337,27 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/account/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } - /// 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. - pub async fn list_logs( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/account/logs".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - /// Enable or disable MFA on an account. pub async fn update_mfa(&self, mfa: bool) -> crate::error::Result { let mut params = HashMap::new(); @@ -375,6 +426,7 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/mfa/authenticators/{type}" .to_string() @@ -928,6 +980,7 @@ impl Account { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/sessions".to_string(); @@ -958,6 +1011,9 @@ impl Account { /// 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 @@ -1137,9 +1193,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1158,9 +1224,19 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1176,10 +1252,21 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1289,6 +1376,10 @@ impl Account { /// 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). diff --git a/src/services/activities.rs b/src/services/activities.rs index c9017d0..b482235 100644 --- a/src/services/activities.rs +++ b/src/services/activities.rs @@ -55,9 +55,19 @@ impl Activities { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let event_id = event_id.into(); + if event_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"eventId\"", + None, + String::new(), + )); + } + let path = "/activities/events/{eventId}" .to_string() - .replace("{eventId}", &event_id.into().to_string()); + .replace("{eventId}", &event_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/advisor.rs b/src/services/advisor.rs index 084c5f2..ae581e6 100644 --- a/src/services/advisor.rs +++ b/src/services/advisor.rs @@ -61,9 +61,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -76,10 +86,21 @@ impl Advisor { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -107,9 +128,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -126,10 +157,30 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + + let insight_id = insight_id.into(); + if insight_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"insightId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights/{insightId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()) - .replace("{insightId}", &insight_id.into().to_string()); + .replace("{reportId}", &report_id) + .replace("{insightId}", &insight_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/apps.rs b/src/services/apps.rs index 46c3c4b..8ed7d09 100644 --- a/src/services/apps.rs +++ b/src/services/apps.rs @@ -189,9 +189,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -301,9 +309,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -311,18 +327,23 @@ impl Apps { } /// Delete an application by its unique ID. - pub async fn delete( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -351,9 +372,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -372,10 +403,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -389,16 +440,36 @@ impl Apps { &self, app_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -423,10 +494,30 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -453,9 +544,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -474,9 +573,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -493,10 +600,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,16 +635,36 @@ impl Apps { &self, app_id: impl Into, key_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -544,9 +691,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/labels" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -573,9 +730,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -592,9 +759,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -611,10 +788,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -626,16 +823,36 @@ impl Apps { &self, app_id: impl Into, secret_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -654,9 +871,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/team" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/team".to_string().replace("{appId}", &app_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -664,18 +889,25 @@ impl Apps { } /// Revoke all tokens for an application by its unique ID. - pub async fn delete_tokens( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_tokens(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/avatars.rs b/src/services/avatars.rs index 60c40ab..6a529a4 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -236,9 +236,9 @@ impl Avatars { } /// 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, @@ -483,27 +483,6 @@ impl crate::services::Service for Avatars { mod tests { use super::*; - #[tokio::test] - async fn test_update_photo_sends_one_request_whatever_the_chunk_size() { - use wiremock::matchers::{method, path}; - use wiremock::{Mock, MockServer, ResponseTemplate}; - - let server = MockServer::start().await; - Mock::given(method("PUT")) - .and(path("/avatars/photo")) - .respond_with(ResponseTemplate::new(500)) - .mount(&server) - .await; - - let client = Client::new().set_endpoint(server.uri()).set_chunk_size(1); - let file = InputFile::from_bytes(vec![0u8; 10], "photo.png", Some("image/png")); - let _ = Avatars::new(&client).update_photo(file).await; - - let requests = server.received_requests().await.unwrap(); - assert_eq!(requests.len(), 1); - assert!(requests[0].headers.get("content-range").is_none()); - } - #[test] fn test_avatars_creation() { let client = Client::new(); diff --git a/src/services/backups.rs b/src/services/backups.rs index 3379cb7..20fb617 100644 --- a/src/services/backups.rs +++ b/src/services/backups.rs @@ -77,9 +77,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -87,18 +97,25 @@ impl Backups { } /// Delete an existing archive for a project. - pub async fn delete_archive( - &self, - archive_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_archive(&self, archive_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -173,9 +190,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -208,9 +235,19 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -218,18 +255,25 @@ impl Backups { } /// Delete a policy using it's ID. - pub async fn delete_policy( - &self, - policy_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_policy(&self, policy_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -325,9 +369,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/backups/restorations/{restorationId}" .to_string() - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/databases.rs b/src/services/databases.rs index 6d30c67..c9f3774 100644 --- a/src/services/databases.rs +++ b/src/services/databases.rs @@ -134,9 +134,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -178,10 +198,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -221,9 +262,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -248,9 +299,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -263,10 +324,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -298,9 +370,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -348,9 +430,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -368,10 +460,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -413,10 +525,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -433,11 +565,32 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -465,10 +618,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,10 +681,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -550,11 +743,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -584,10 +807,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -617,11 +860,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -651,10 +924,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -684,11 +977,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -718,10 +1041,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -751,11 +1094,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -795,10 +1168,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -837,11 +1230,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -881,10 +1304,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -923,11 +1366,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -967,10 +1440,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1502,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1043,10 +1566,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1076,11 +1619,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1106,10 +1679,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1139,11 +1732,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1178,10 +1801,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1211,11 +1854,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1250,10 +1923,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1283,11 +1976,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1313,10 +2036,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1346,11 +2089,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1376,10 +2149,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1409,11 +2202,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1456,10 +2279,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1487,12 +2330,42 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1529,10 +2402,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1567,11 +2460,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1606,10 +2529,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1639,11 +2582,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1673,10 +2646,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1706,11 +2699,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1747,10 +2770,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1785,11 +2828,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1807,11 +2880,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1828,12 +2931,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1870,10 +3004,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1909,10 +3063,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1939,10 +3113,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1969,10 +3163,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2007,10 +3221,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2040,10 +3274,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2073,11 +3327,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2114,11 +3398,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2153,11 +3467,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2178,12 +3522,43 @@ impl Databases { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2216,13 +3591,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2255,13 +3670,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2289,10 +3744,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2301,7 +3776,9 @@ impl Databases { /// Creates an index on the attributes listed. Your index should include all /// the attributes you will query in a single request. - /// Attributes can be `key`, `fulltext`, and `unique`. + /// Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + /// `trigram` is only available on PostgreSQL and lets `contains`, + /// `startsWith`, and `endsWith` queries on string attributes use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2333,10 +3810,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2354,11 +3851,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2375,12 +3902,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/documents_db.rs b/src/services/documents_db.rs index 6f761f7..ca88c34 100644 --- a/src/services/documents_db.rs +++ b/src/services/documents_db.rs @@ -86,8 +86,8 @@ impl DocumentsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -381,9 +463,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +493,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -444,10 +556,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -464,11 +596,32 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -505,10 +658,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -544,10 +717,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -574,10 +767,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -604,10 +817,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -642,10 +875,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -675,10 +928,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -708,11 +981,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -749,11 +1052,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -788,11 +1121,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -813,12 +1176,43 @@ impl DocumentsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -851,13 +1245,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -890,13 +1324,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -924,10 +1398,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -968,10 +1462,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -989,11 +1503,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1010,12 +1554,43 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1044,9 +1619,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1077,9 +1662,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1096,9 +1691,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1116,9 +1721,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/functions.rs b/src/services/functions.rs index 3dd0131..be83cfa 100644 --- a/src/services/functions.rs +++ b/src/services/functions.rs @@ -224,9 +224,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -342,9 +352,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -356,10 +376,21 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -379,9 +410,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployment" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -413,9 +454,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -455,12 +506,30 @@ impl Functions { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -484,9 +553,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/duplicate" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -522,9 +601,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/template" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -551,9 +640,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/vcs" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -570,10 +669,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -589,11 +708,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -620,10 +760,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/download" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -645,10 +805,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/status" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -676,9 +856,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -723,9 +913,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -742,10 +942,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -761,11 +981,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -792,9 +1033,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -822,9 +1073,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -841,10 +1102,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -874,10 +1155,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -893,11 +1194,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/messaging.rs b/src/services/messaging.rs index 71dc9c2..596c87a 100644 --- a/src/services/messaging.rs +++ b/src/services/messaging.rs @@ -222,9 +222,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/email/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -433,9 +443,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/push/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -538,9 +558,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/sms/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -556,9 +586,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -571,10 +611,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -601,9 +652,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}/targets" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -724,9 +785,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/apns/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -860,9 +931,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/fcm/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -969,9 +1050,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/mailgun/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1044,9 +1135,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/msg91/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1137,9 +1238,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/resend/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1230,9 +1341,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/sendgrid/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1339,9 +1460,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/ses/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1478,9 +1609,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/smtp/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1553,9 +1694,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/telesign/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1628,9 +1779,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/textmagic/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1703,9 +1864,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/twilio/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1778,9 +1949,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/vonage/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1796,9 +1977,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1813,10 +2004,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1897,9 +2099,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1935,9 +2147,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1949,10 +2171,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1983,9 +2216,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2006,9 +2249,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2025,10 +2278,30 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2044,11 +2317,32 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/mongo.rs b/src/services/mongo.rs index 9b57b1e..1cd671e 100644 --- a/src/services/mongo.rs +++ b/src/services/mongo.rs @@ -121,8 +121,8 @@ impl Mongo { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mongo { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mongo { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mongo { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -682,9 +909,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -707,9 +944,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -735,9 +982,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -768,9 +1025,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -787,9 +1054,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -806,9 +1083,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -841,9 +1128,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -879,9 +1176,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -899,10 +1206,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -920,9 +1247,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -942,9 +1279,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/mysql.rs b/src/services/mysql.rs index 434f42b..092d103 100644 --- a/src/services/mysql.rs +++ b/src/services/mysql.rs @@ -121,8 +121,8 @@ impl Mysql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mysql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mysql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mysql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -688,9 +915,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -719,9 +956,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -744,9 +991,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -772,9 +1029,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -805,9 +1072,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -824,9 +1101,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -843,9 +1130,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -896,9 +1193,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -915,9 +1222,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -950,9 +1267,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -988,9 +1315,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1008,10 +1345,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1029,9 +1386,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1051,9 +1418,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/oauth2.rs b/src/services/oauth2.rs index 834934a..9691f1f 100644 --- a/src/services/oauth2.rs +++ b/src/services/oauth2.rs @@ -81,7 +81,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -120,7 +120,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -165,7 +168,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -204,7 +207,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -238,7 +244,7 @@ impl Oauth2 { client_id: Option<&str>, scope: Option<&str>, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -252,7 +258,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -318,6 +327,16 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let grant_id = grant_id.into(); + if grant_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"grantId\"", + None, + String::new(), + )); + } + let path = "/oauth2/{project_id}/grants/{grant_id}" .to_string() .replace( @@ -329,7 +348,7 @@ impl Oauth2 { .cloned() .unwrap_or_default(), ) - .replace("{grant_id}", &grant_id.into().to_string()); + .replace("{grant_id}", &grant_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -430,7 +449,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -462,7 +481,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -603,7 +625,7 @@ impl Oauth2 { client_secret: Option<&str>, code_verifier: Option<&str>, redirect_uri: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -630,7 +652,10 @@ impl Oauth2 { params.insert("redirect_uri".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); diff --git a/src/services/organization.rs b/src/services/organization.rs index 176b0f5..a574ade 100644 --- a/src/services/organization.rs +++ b/src/services/organization.rs @@ -60,6 +60,7 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/organization".to_string(); @@ -129,9 +130,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -155,9 +166,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -170,130 +191,25 @@ impl Organization { pub async fn delete_installation( &self, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}" - .to_string() - .replace("{installationId}", &installation_id.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a list of all API keys from the current organization. - pub async fn list_keys( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Create a new organization API key. - pub async fn create_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("keyId".to_string(), json!(key_id.into())); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::POST, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a key by its unique ID. This endpoint returns details about a specific - /// API key in your organization including its scopes. - pub async fn get_key( - &self, - key_id: impl Into, - ) -> crate::error::Result { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Update a key by its unique ID. Use this endpoint to update the name, - /// scopes, or expiration time of an API key. - pub async fn update_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Delete a key by its unique ID. Once deleted, the key can no longer be used - /// to authenticate API calls. - pub async fn delete_key(&self, key_id: impl Into) -> crate::error::Result<()> { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" + let path = "/organization/installations/{installationId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -382,9 +298,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -406,9 +332,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -425,10 +361,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -496,13 +443,25 @@ impl Organization { project_id: impl Into, ) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -518,9 +477,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } + let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -532,10 +501,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/postgresql.rs b/src/services/postgresql.rs index e736abe..10a50a2 100644 --- a/src/services/postgresql.rs +++ b/src/services/postgresql.rs @@ -121,8 +121,8 @@ impl Postgresql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Postgresql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Postgresql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Postgresql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -688,9 +915,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -706,9 +943,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -728,9 +975,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -749,10 +1006,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let extension_name = extension_name.into(); + if extension_name.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"extensionName\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions/{extensionName}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{extensionName}", &extension_name.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{extensionName}", &extension_name); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -781,9 +1058,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -806,9 +1093,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -834,9 +1131,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -867,9 +1174,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -886,9 +1203,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -905,9 +1232,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -958,9 +1295,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -977,9 +1324,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1012,9 +1369,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1050,9 +1417,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1070,10 +1447,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1091,9 +1488,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1113,9 +1520,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/presences.rs b/src/services/presences.rs index 2954c14..6b777c6 100644 --- a/src/services/presences.rs +++ b/src/services/presences.rs @@ -64,9 +64,19 @@ impl Presences { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -102,9 +112,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -148,9 +168,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -162,10 +192,21 @@ impl Presences { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/project.rs b/src/services/project.rs index 43c2af2..24f9252 100644 --- a/src/services/project.rs +++ b/src/services/project.rs @@ -27,11 +27,13 @@ impl Project { /// Get a project. pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -40,6 +42,7 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); @@ -266,9 +269,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -294,9 +307,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -309,10 +332,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -402,9 +436,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -424,9 +468,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -439,10 +493,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1253,8 +1318,8 @@ impl Project { &self, client_id: Option<&str>, client_secret: Option<&str>, - prompt: Option>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1263,12 +1328,12 @@ impl Project { if let Some(value) = client_secret { params.insert("clientSecret".to_string(), json!(value)); } - if let Some(value) = prompt { - params.insert("prompt".to_string(), json!(value)); - } if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } + if let Some(value) = prompt { + params.insert("prompt".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); @@ -2147,7 +2212,7 @@ impl Project { } /// 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. pub async fn update_android_platform( &self, platform_id: impl Into, @@ -2168,9 +2233,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/android/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2222,9 +2297,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/apple/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2270,9 +2355,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/linux/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2318,9 +2413,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/web/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2372,9 +2477,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/windows/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2391,9 +2506,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2409,10 +2534,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -3027,6 +3163,7 @@ impl Project { ); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project/smtp/tests".to_string(); @@ -3197,9 +3334,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -3228,9 +3375,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -3245,10 +3402,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/proxy.rs b/src/services/proxy.rs index 2507b73..ad548f3 100644 --- a/src/services/proxy.rs +++ b/src/services/proxy.rs @@ -29,6 +29,8 @@ impl Proxy { /// /// 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. pub async fn create_invalidation( &self, domain: impl Into, @@ -193,9 +195,19 @@ impl Proxy { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -207,10 +219,21 @@ impl Proxy { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -230,9 +253,19 @@ impl Proxy { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}/status" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/sites.rs b/src/services/sites.rs index 150a50d..99a6e87 100644 --- a/src/services/sites.rs +++ b/src/services/sites.rs @@ -217,9 +217,17 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +339,17 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -345,10 +361,19 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -368,9 +393,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployment" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -402,9 +437,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -443,12 +488,30 @@ impl Sites { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -468,9 +531,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/duplicate" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -506,9 +579,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/template" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -535,9 +618,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/vcs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -554,10 +647,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -573,11 +686,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -604,10 +738,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/download" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -629,10 +783,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/status" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -660,9 +834,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -679,10 +863,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -694,16 +898,36 @@ impl Sites { &self, site_id: impl Into, log_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -730,9 +954,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -760,9 +994,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -779,10 +1023,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -812,10 +1076,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -831,11 +1115,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/storage.rs b/src/services/storage.rs index 4736eaf..2f49674 100644 --- a/src/services/storage.rs +++ b/src/services/storage.rs @@ -127,9 +127,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -191,9 +201,19 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -205,10 +225,21 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -240,9 +271,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -293,12 +334,23 @@ impl Storage { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client - .file_upload( + .upload( + Method::POST, &path, Some(api_headers), params, @@ -320,10 +372,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -353,10 +425,30 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -373,11 +465,32 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -400,10 +513,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/download" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -473,10 +606,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/preview" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/view" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/tables_db.rs b/src/services/tables_db.rs index a9f0f21..1a3da92 100644 --- a/src/services/tables_db.rs +++ b/src/services/tables_db.rs @@ -92,8 +92,8 @@ impl TablesDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -163,9 +163,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -190,9 +200,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -207,10 +227,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -231,9 +262,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -250,9 +291,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -289,9 +340,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -304,10 +365,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -336,9 +408,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -355,9 +437,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -382,9 +474,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +503,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -417,16 +539,36 @@ impl TablesDB { &self, database_id: impl Into, migration_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -449,10 +591,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}/cutovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -483,9 +645,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -502,9 +674,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -522,9 +704,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -556,9 +748,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +808,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -626,10 +838,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -671,10 +903,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -691,11 +943,32 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -723,10 +996,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -766,10 +1059,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -808,11 +1121,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -842,10 +1185,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -875,11 +1238,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -909,10 +1302,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -942,11 +1355,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -976,10 +1419,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1472,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1053,10 +1546,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1095,11 +1608,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1139,10 +1682,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1181,11 +1744,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1225,10 +1818,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1267,11 +1880,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1301,10 +1944,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1334,11 +1997,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1364,10 +2057,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1397,11 +2110,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1436,10 +2179,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1469,11 +2232,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1508,10 +2301,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1541,11 +2354,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1571,10 +2414,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1604,11 +2467,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1634,10 +2527,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1667,11 +2580,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1711,16 +2654,98 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) .await } + /// Update relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + pub async fn update_relationship_column( + &self, + database_id: impl Into, + table_id: impl Into, + key: impl Into, + on_delete: Option, + new_key: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = on_delete { + params.insert("onDelete".to_string(), json!(value)); + } + if let Some(value) = new_key { + params.insert("newKey".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Create a string column. #[allow(clippy::too_many_arguments)] pub async fn create_string_column( @@ -1751,10 +2776,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1789,11 +2834,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1828,10 +2903,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1861,11 +2956,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1895,10 +3020,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1928,11 +3073,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1969,10 +3144,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2007,11 +3202,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2029,11 +3254,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2050,47 +3305,46 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" - .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } - /// Update relationship column. [Learn more about relationship - /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - pub async fn update_relationship_column( - &self, - database_id: impl Into, - table_id: impl Into, - key: impl Into, - on_delete: Option, - new_key: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = on_delete { - params.insert("onDelete".to_string(), json!(value)); + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); } - if let Some(value) = new_key { - params.insert("newKey".to_string(), json!(value)); + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship" + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client - .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } @@ -2115,10 +3369,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2127,7 +3401,9 @@ impl TablesDB { /// Creates an index on the columns listed. Your index should include all the /// columns you will query in a single request. - /// Type can be `key`, `fulltext`, or `unique`. + /// Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + /// is only available on PostgreSQL and lets `contains`, `startsWith`, and + /// `endsWith` queries on string columns use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2159,10 +3435,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2180,11 +3476,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2201,12 +3527,43 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2243,10 +3600,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2282,10 +3659,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2312,10 +3709,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2342,10 +3759,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2379,10 +3816,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2412,10 +3869,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2445,11 +3922,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2486,11 +3993,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2525,11 +4062,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2550,12 +4117,43 @@ impl TablesDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2588,12 +4186,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2626,12 +4264,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/teams.rs b/src/services/teams.rs index 5f55c5b..68d6978 100644 --- a/src/services/teams.rs +++ b/src/services/teams.rs @@ -93,9 +93,17 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -114,9 +122,17 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -129,10 +145,19 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -159,9 +184,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -187,9 +222,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -207,10 +252,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -235,10 +300,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -252,16 +337,36 @@ impl Teams { &self, team_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -294,9 +399,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -362,9 +477,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -383,10 +508,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -411,10 +556,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -432,11 +597,32 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -463,10 +649,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}/status" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -484,9 +690,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -507,9 +723,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) diff --git a/src/services/tokens.rs b/src/services/tokens.rs index 43b9063..d58c5cb 100644 --- a/src/services/tokens.rs +++ b/src/services/tokens.rs @@ -46,10 +46,30 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -72,10 +92,30 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -91,9 +131,19 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -115,9 +165,19 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -129,10 +189,21 @@ impl Tokens { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/users.rs b/src/services/users.rs index 7cd8e38..73b7d8b 100644 --- a/src/services/users.rs +++ b/src/services/users.rs @@ -184,10 +184,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/users/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -377,9 +388,17 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -396,10 +415,19 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -418,9 +446,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/email" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -431,7 +469,10 @@ impl Users { /// 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. pub async fn update_impersonator( &self, user_id: impl Into, @@ -443,9 +484,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/impersonator" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -472,9 +523,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/jwts" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -504,41 +565,22 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/labels" - .to_string() - .replace("{userId}", &user_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Get the user activity logs list by its unique ID. - pub async fn list_logs( - &self, - user_id: impl Into, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/logs" + let path = "/users/{userId}/labels" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) + .call(Method::PUT, &path, Some(api_headers), Some(params)) .await } @@ -566,9 +608,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/memberships" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -587,9 +639,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -605,10 +667,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/mfa/authenticators/{type}" .to_string() - .replace("{userId}", &user_id.into().to_string()) + .replace("{userId}", &user_id) .replace("{type}", &r#type.to_string()); self.client @@ -627,10 +700,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let challenge_id = challenge_id.into(); + if challenge_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"challengeId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/challenges/{challengeId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{challengeId}", &challenge_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{challengeId}", &challenge_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -646,9 +739,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/factors" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -667,9 +770,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -689,9 +802,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -711,9 +834,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -732,9 +865,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/name" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -917,9 +1060,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/password" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -938,9 +1091,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -956,9 +1119,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -979,9 +1152,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1001,9 +1184,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1025,9 +1218,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1039,10 +1242,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1058,11 +1272,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions/{sessionId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1082,9 +1317,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/status" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1111,9 +1356,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1144,9 +1399,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1163,10 +1428,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1196,10 +1481,30 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1215,11 +1520,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1247,9 +1573,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/tokens" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1268,9 +1604,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1289,9 +1635,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/vectors_db.rs b/src/services/vectors_db.rs index be3894b..a89bf38 100644 --- a/src/services/vectors_db.rs +++ b/src/services/vectors_db.rs @@ -86,8 +86,8 @@ impl VectorsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -375,9 +457,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -395,10 +487,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -438,10 +550,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -458,11 +590,32 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -538,10 +711,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -568,10 +761,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -598,10 +811,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -636,10 +869,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,10 +922,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -712,10 +985,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/query" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -745,11 +1038,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -786,11 +1109,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -825,11 +1178,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -850,12 +1233,43 @@ impl VectorsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -883,10 +1297,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -927,10 +1361,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -948,11 +1402,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -969,12 +1453,43 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1003,9 +1518,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1036,9 +1561,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1055,9 +1590,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1075,9 +1620,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/webhooks.rs b/src/services/webhooks.rs index 0e3e171..c53feda 100644 --- a/src/services/webhooks.rs +++ b/src/services/webhooks.rs @@ -112,9 +112,19 @@ impl Webhooks { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -176,10 +196,21 @@ impl Webhooks { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}/secret" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/tests/tests.rs b/tests/tests.rs index 2821bc3..d47a3bf 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,11 +1,13 @@ use appwrite::{ Client, + enums::PresetQuality, id::ID, input_file::InputFile, operator::{self, Condition}, permission::Permission, query::Query, role::Role, + topic, services::*, }; use serde_json::json; @@ -112,12 +114,50 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re Err(e) => eprintln!("general.redirected => error {}", e), } + for (id, plain) in [("", "0"), ("0", "")] { + let error = general.validate_path(plain, Some(id)).await.unwrap_err(); + assert_eq!(error.code, 0); + println!("{}", error.message); + } + println!("{}", general.validate_path("0", Some("0")).await?.result); + println!("{}", general.validate_path("0", None).await?.result); + + let zone: String = Plaintext::new(&client).get_zone().await?; + println!("{}", zone); + println!("{}", general.get_mixed().await?.result); + let plaintext = Plaintext::new(&client); + let records = "www 3600 IN A 192.0.2.1"; + println!("{}", plaintext.import_zone(records, None).await?); + let zone_file = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", plaintext.import_zone(records, Some(zone_file)).await?); + + let message = "conversation without a required file"; + println!("{}", general.optional_upload(message, None, None).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), None).await?.result); + println!("{}", general.optional_upload(message, None, Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + test_general_upload(client, string_in_array).await?; test_large_upload(client, string_in_array).await?; + // A PUT upload has no chunked form, so it must go in one request even with tiny chunks. + let small_chunks = client.set_chunk_size(1024); + let profile = General::new(&small_chunks).upload_generic(InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?).await?; + println!("{}", profile.prefs().get::("result").unwrap_or_default()); // Extended General Responses test_general_download(client).await?; + let preset = general.get_preset(None).await?; + println!("preset: name={}, count={}, enabled={}", preset.name, preset.count, preset.enabled); + for item in general.list_presets().await?.presets { + println!("preset: name={}, count={}, enabled={}", item.name, item.count, item.enabled); + } + println!("empty presets: {}", general.list_empty_presets().await?.presets.len()); + println!("preset verified: {}", preset.verified.map_or("null".to_string(), |verified| verified.to_string())); + println!("preset quality default: {}", PresetQuality::default()); + // Exception Responses match general.error400().await { Ok(_) => {}, @@ -145,7 +185,7 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re println!("Invalid endpoint URL: htp://cloud.appwrite.io/v1"); - let _ = general.empty().await; + let (): () = general.empty().await?; // Test Queries test_queries(); @@ -155,6 +195,7 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re // Test Id Helpers test_id_helpers(); + test_topic_helpers(); // Test Operator Helpers test_operator_helpers(); @@ -313,6 +354,29 @@ fn test_id_helpers() { println!("{}", ID::custom("custom_id")); } +fn test_topic_helpers() { + println!("{}", topic::path(&["user", "123", "notification"]).unwrap()); + println!("{}", topic::path(&["org", "42", "user", "123"]).unwrap().path(&["notification"]).unwrap()); + println!("{}", topic::path(&["user"]).unwrap().any().path(&["notification"]).unwrap()); + println!("{}", topic::path(&["chat"]).unwrap().any().any().path(&["message"]).unwrap()); + println!("{}", topic::path(&["org"]).unwrap().any().path(&["logs"]).unwrap().all()); + println!("{}", topic::any().path(&["notification"]).unwrap()); + println!("{}", topic::all()); + let cases: Vec<(&str, Vec<&str>)> = vec![ + ("empty path", vec![]), + ("empty level", vec!["user", ""]), + ("slash", vec!["user/123"]), + ("plus", vec!["user", "a+b"]), + ("hash", vec!["user", "#"]), + ]; + for (name, levels) in cases { + match topic::path(&levels) { + Ok(_) => println!("Topic {}:failed", name), + Err(_) => println!("Topic {}:passed", name), + } + } +} + fn test_operator_helpers() { println!("{}", operator::increment()); println!("{}", operator::increment_with_max(5, 100)); From 2b83fe5209940324b2cf77fa716d578fa05dceea Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 18:22:00 +0100 Subject: [PATCH 2/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 307 ++- Cargo.toml | 2 +- README.md | 6 +- docs/examples/account/delete-consent-token.md | 4 +- docs/examples/account/delete-consent.md | 4 +- docs/examples/account/list-logs.md | 23 - docs/examples/apps/delete-installation.md | 4 +- docs/examples/apps/delete-key.md | 4 +- docs/examples/apps/delete-secret.md | 4 +- docs/examples/apps/delete-tokens.md | 4 +- docs/examples/apps/delete.md | 4 +- docs/examples/backups/delete-archive.md | 4 +- docs/examples/backups/delete-policy.md | 4 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 2 +- docs/examples/documentsdb/create-documents.md | 2 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 2 +- .../embeddings/create-text-embeddings.md | 2 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/delete-backup-policy.md | 4 +- docs/examples/mongo/delete-backup.md | 4 +- docs/examples/mongo/delete.md | 4 +- docs/examples/mysql/delete-backup-policy.md | 4 +- docs/examples/mysql/delete-backup.md | 4 +- docs/examples/mysql/delete.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/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 25 - .../organization/delete-installation.md | 4 +- docs/examples/organization/delete-key.md | 20 - docs/examples/organization/get-key.md | 22 - docs/examples/organization/list-keys.md | 23 - docs/examples/organization/update-key.md | 25 - .../postgresql/delete-backup-policy.md | 4 +- docs/examples/postgresql/delete-backup.md | 4 +- docs/examples/postgresql/delete.md | 4 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- docs/examples/sites/delete-log.md | 4 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 2 +- docs/examples/tablesdb/delete-migration.md | 4 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 2 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/delete-installation.md | 4 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/list-logs.md | 24 - docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 2 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 2 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 2 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- src/client.rs | 216 +- src/enums/billing_plan_group.rs | 5 +- src/enums/execution_method.rs | 2 +- src/enums/image_gravity.rs | 6 +- src/enums/mod.rs | 2 - src/enums/organization_key_scopes.rs | 72 - src/lib.rs | 5 +- src/models/activity_event.rs | 145 ++ src/models/activity_event_list.rs | 10 + src/models/additional_resource.rs | 30 + src/models/algo_argon2.rs | 20 + src/models/algo_bcrypt.rs | 5 + src/models/algo_md5.rs | 5 + src/models/algo_phpass.rs | 5 + src/models/algo_scrypt.rs | 25 + src/models/algo_scrypt_modified.rs | 20 + src/models/algo_sha.rs | 5 + src/models/app.rs | 130 ++ src/models/app_installation.rs | 45 + src/models/app_installation_list.rs | 10 + src/models/app_key.rs | 40 + src/models/app_key_list.rs | 10 + src/models/app_scope.rs | 25 + src/models/app_scope_list.rs | 10 + src/models/app_secret.rs | 40 + src/models/app_secret_list.rs | 10 + src/models/app_secret_plaintext.rs | 40 + src/models/apps_list.rs | 10 + src/models/attribute_bigint.rs | 30 + src/models/attribute_boolean.rs | 30 + src/models/attribute_datetime.rs | 30 + src/models/attribute_email.rs | 35 + src/models/attribute_enum.rs | 40 + src/models/attribute_float.rs | 30 + src/models/attribute_integer.rs | 30 + src/models/attribute_ip.rs | 35 + src/models/attribute_line.rs | 30 + src/models/attribute_list.rs | 10 + src/models/attribute_longtext.rs | 30 + src/models/attribute_mediumtext.rs | 30 + src/models/attribute_object.rs | 30 + src/models/attribute_point.rs | 30 + src/models/attribute_polygon.rs | 30 + src/models/attribute_relationship.rs | 55 + src/models/attribute_string.rs | 35 + src/models/attribute_text.rs | 30 + src/models/attribute_url.rs | 35 + src/models/attribute_varchar.rs | 35 + src/models/attribute_vector.rs | 35 + src/models/backup_archive.rs | 72 +- src/models/backup_archive_list.rs | 10 + src/models/backup_policy.rs | 50 + src/models/backup_policy_list.rs | 10 + src/models/backup_restoration.rs | 72 +- src/models/backup_restoration_list.rs | 10 + src/models/billing_plan.rs | 335 ++- src/models/billing_plan_addon_details.rs | 35 + src/models/billing_plan_supported_addons.rs | 15 + src/models/block.rs | 80 +- src/models/bucket.rs | 70 + src/models/bucket_list.rs | 10 + src/models/collection.rs | 60 + src/models/collection_list.rs | 10 + src/models/column_bigint.rs | 30 + src/models/column_boolean.rs | 30 + src/models/column_datetime.rs | 30 + src/models/column_email.rs | 35 + src/models/column_enum.rs | 40 + src/models/column_float.rs | 30 + src/models/column_index.rs | 45 + src/models/column_index_list.rs | 10 + src/models/column_integer.rs | 30 + src/models/column_ip.rs | 35 + src/models/column_line.rs | 30 + src/models/column_list.rs | 10 + src/models/column_longtext.rs | 30 + src/models/column_mediumtext.rs | 30 + src/models/column_point.rs | 30 + src/models/column_polygon.rs | 30 + src/models/column_relationship.rs | 55 + src/models/column_string.rs | 35 + src/models/column_text.rs | 30 + src/models/column_url.rs | 35 + src/models/column_varchar.rs | 35 + src/models/continent.rs | 10 + src/models/continent_list.rs | 10 + src/models/country.rs | 10 + src/models/country_list.rs | 10 + src/models/currency.rs | 35 + src/models/currency_list.rs | 10 + src/models/database.rs | 35 +- src/models/database_list.rs | 10 + src/models/database_migration.rs | 85 + src/models/database_migration_list.rs | 10 + src/models/database_status.rs | 74 +- src/models/database_status_connections.rs | 10 + src/models/database_status_replica.rs | 15 + src/models/database_status_volume.rs | 20 + src/models/dedicated_database.rs | 316 ++- src/models/dedicated_database_backup.rs | 60 + src/models/dedicated_database_backup_list.rs | 10 + .../dedicated_database_backup_storage.rs | 25 + src/models/dedicated_database_branch.rs | 69 +- src/models/dedicated_database_branch_list.rs | 10 + src/models/dedicated_database_execution.rs | 30 + .../dedicated_database_execution_column.rs | 10 + src/models/dedicated_database_extensions.rs | 15 + src/models/dedicated_database_list.rs | 10 + src/models/dedicated_database_member.rs | 15 + src/models/dedicated_database_operation.rs | 40 + .../dedicated_database_operation_list.rs | 10 + src/models/dedicated_database_pitr_windows.rs | 10 + src/models/dedicated_database_pooler.rs | 50 + src/models/dedicated_database_replicas.rs | 30 + src/models/dedicated_database_restoration.rs | 105 +- .../dedicated_database_restoration_list.rs | 10 + .../dedicated_database_specification.rs | 121 +- .../dedicated_database_specification_list.rs | 19 +- ...edicated_database_specification_pricing.rs | 68 - src/models/deployment.rs | 130 ++ src/models/deployment_list.rs | 10 + src/models/dev_key.rs | 104 - src/models/document.rs | 35 + src/models/document_list.rs | 10 + src/models/email_template.rs | 40 + src/models/email_template_list.rs | 10 + src/models/embedding.rs | 20 + src/models/embedding_list.rs | 10 + src/models/ephemeral_key.rs | 45 + src/models/execution.rs | 82 +- src/models/execution_list.rs | 10 + src/models/file.rs | 80 + src/models/file_list.rs | 10 + src/models/framework.rs | 25 + src/models/framework_adapter.rs | 20 + src/models/framework_list.rs | 10 + src/models/function.rs | 160 ++ src/models/function_list.rs | 10 + src/models/headers.rs | 10 + src/models/identity.rs | 69 +- src/models/identity_list.rs | 10 + src/models/index.rs | 40 + src/models/index_list.rs | 10 + src/models/insight.rs | 70 + src/models/insight_cta.rs | 20 + src/models/insight_list.rs | 10 + src/models/jwt.rs | 5 + src/models/key.rs | 45 + src/models/key_list.rs | 10 + src/models/language.rs | 15 + src/models/language_list.rs | 10 + src/models/locale.rs | 35 + src/models/locale_code.rs | 10 + src/models/locale_code_list.rs | 10 + src/models/log.rs | 235 -- src/models/log_list.rs | 49 - src/models/membership.rs | 75 + src/models/membership_list.rs | 10 + src/models/message.rs | 50 + src/models/message_list.rs | 10 + src/models/mfa_challenge.rs | 20 + src/models/mfa_challenge_secret.rs | 25 + src/models/mfa_factors.rs | 25 + src/models/mfa_recovery_codes.rs | 5 + src/models/mfa_type.rs | 10 + src/models/mock_number.rs | 20 + src/models/mock_number_list.rs | 10 + src/models/mod.rs | 36 +- src/models/o_auth2_amazon.rs | 20 + src/models/o_auth2_apple.rs | 68 +- src/models/o_auth2_appwrite.rs | 20 + src/models/o_auth2_auth0.rs | 44 +- src/models/o_auth2_authentik.rs | 25 + src/models/o_auth2_autodesk.rs | 20 + src/models/o_auth2_bitbucket.rs | 20 + src/models/o_auth2_bitly.rs | 20 + src/models/o_auth2_box.rs | 20 + src/models/o_auth2_cloudflare.rs | 20 + src/models/o_auth2_dailymotion.rs | 20 + src/models/o_auth2_discord.rs | 39 +- src/models/o_auth2_disqus.rs | 20 + src/models/o_auth2_dropbox.rs | 20 + src/models/o_auth2_etsy.rs | 20 + src/models/o_auth2_facebook.rs | 20 + src/models/o_auth2_figma.rs | 20 + src/models/o_auth2_fusion_auth.rs | 25 + src/models/o_auth2_github.rs | 39 +- src/models/o_auth2_gitlab.rs | 25 + src/models/o_auth2_google.rs | 63 +- src/models/o_auth2_hugging_face.rs | 20 + src/models/o_auth2_keycloak.rs | 30 + src/models/o_auth2_kick.rs | 20 + src/models/o_auth2_linkedin.rs | 20 + src/models/o_auth2_microsoft.rs | 44 +- src/models/o_auth2_notion.rs | 20 + src/models/o_auth2_oidc.rs | 65 +- src/models/o_auth2_okta.rs | 49 +- src/models/o_auth2_paypal.rs | 20 + src/models/o_auth2_podio.rs | 20 + src/models/o_auth2_provider_list.rs | 10 + src/models/o_auth2_resend.rs | 20 + src/models/o_auth2_salesforce.rs | 39 +- src/models/o_auth2_slack.rs | 20 + src/models/o_auth2_spotify.rs | 20 + src/models/o_auth2_stripe.rs | 20 + src/models/o_auth2_tradeshift.rs | 20 + src/models/o_auth2_twitch.rs | 20 + src/models/o_auth2_word_press.rs | 20 + src/models/o_auth2_x.rs | 20 + src/models/o_auth2_yahoo.rs | 20 + src/models/o_auth2_yandex.rs | 20 + src/models/o_auth2_zoho.rs | 39 +- src/models/o_auth2_zoom.rs | 20 + src/models/oauth2_approve.rs | 5 + src/models/oauth2_authorize.rs | 10 + src/models/oauth2_consent.rs | 50 + src/models/oauth2_consent_list.rs | 10 + src/models/oauth2_consent_token.rs | 55 + src/models/oauth2_consent_token_list.rs | 10 + src/models/oauth2_device_authorization.rs | 30 + src/models/oauth2_grant.rs | 60 + src/models/oauth2_organization.rs | 5 + src/models/oauth2_organization_list.rs | 10 + src/models/oauth2_par.rs | 10 + src/models/oauth2_project.rs | 15 + src/models/oauth2_project_list.rs | 10 + src/models/oauth2_reject.rs | 5 + src/models/oauth2_token.rs | 25 + src/models/organization.rs | 166 +- src/models/passkey.rs | 25 + src/models/passkey_challenge.rs | 25 + src/models/passkey_list.rs | 10 + src/models/phone.rs | 15 + src/models/phone_list.rs | 10 + src/models/platform_android.rs | 44 +- src/models/platform_apple.rs | 25 + src/models/platform_linux.rs | 25 + src/models/platform_list.rs | 10 + src/models/platform_web.rs | 25 + src/models/platform_windows.rs | 25 + src/models/policy_deny_aliased_email.rs | 10 + src/models/policy_deny_corporate_email.rs | 10 + src/models/policy_deny_disposable_email.rs | 10 + src/models/policy_deny_free_email.rs | 10 + src/models/policy_list.rs | 10 + src/models/policy_membership_privacy.rs | 35 + src/models/policy_mfa_factors.rs | 25 + src/models/policy_passkey.rs | 15 + src/models/policy_password_dictionary.rs | 10 + src/models/policy_password_history.rs | 10 + src/models/policy_password_personal_data.rs | 10 + src/models/policy_password_strength.rs | 30 + src/models/policy_session_alert.rs | 10 + src/models/policy_session_duration.rs | 10 + src/models/policy_session_invalidation.rs | 10 + src/models/policy_session_limit.rs | 10 + src/models/policy_user_limit.rs | 10 + src/models/postgres_extension.rs | 20 + src/models/presence.rs | 30 + src/models/presence_list.rs | 10 + src/models/program.rs | 45 + src/models/project.rs | 139 +- src/models/project_auth_method.rs | 5 + src/models/project_list.rs | 10 + src/models/project_protocol.rs | 5 + src/models/project_service.rs | 5 + src/models/provider.rs | 40 + src/models/provider_list.rs | 10 + src/models/proxy_invalidation.rs | 20 + src/models/proxy_rule.rs | 68 +- src/models/proxy_rule_list.rs | 10 + src/models/report.rs | 55 + src/models/report_list.rs | 10 + src/models/resource_token.rs | 35 + src/models/resource_token_list.rs | 10 + src/models/row.rs | 35 + src/models/row_list.rs | 10 + src/models/runtime.rs | 40 + src/models/runtime_list.rs | 10 + src/models/session.rs | 145 ++ src/models/session_list.rs | 10 + src/models/site.rs | 165 ++ src/models/site_list.rs | 10 + src/models/specification.rs | 20 + src/models/specification_list.rs | 10 + src/models/subscriber.rs | 40 + src/models/subscriber_list.rs | 10 + src/models/table.rs | 60 + src/models/table_list.rs | 10 + src/models/target.rs | 40 + src/models/target_list.rs | 10 + src/models/team.rs | 25 + src/models/team_list.rs | 10 + src/models/token.rs | 30 + src/models/token_secret.rs | 30 + src/models/topic.rs | 44 +- src/models/topic_list.rs | 10 + src/models/transaction.rs | 30 + src/models/transaction_list.rs | 10 + src/models/usage_billing_plan.rs | 118 +- src/models/user.rs | 75 + src/models/user_list.rs | 10 + src/models/variable.rs | 40 + src/models/variable_list.rs | 10 + src/models/vectorsdb_collection.rs | 65 + src/models/vectorsdb_collection_list.rs | 10 + src/models/webhook.rs | 67 +- src/models/webhook_list.rs | 10 + src/services/account.rs | 177 +- src/services/activities.rs | 12 +- src/services/advisor.rs | 61 +- src/services/apps.rs | 328 ++- src/services/avatars.rs | 27 +- src/services/backups.rs | 82 +- src/services/databases.rs | 1870 +++++++++++++-- src/services/documents_db.rs | 741 +++++- src/services/functions.rs | 386 ++- src/services/messaging.rs | 352 ++- src/services/mongo.rs | 433 +++- src/services/mysql.rs | 469 +++- src/services/oauth2.rs | 47 +- src/services/organization.rs | 230 +- src/services/postgresql.rs | 517 +++- src/services/presences.rs | 49 +- src/services/project.rs | 212 +- src/services/proxy.rs | 39 +- src/services/sites.rs | 381 ++- src/services/storage.rs | 209 +- src/services/tables_db.rs | 2074 +++++++++++++++-- src/services/teams.rs | 286 ++- src/services/tokens.rs | 85 +- src/services/users.rs | 500 +++- src/services/vectors_db.rs | 669 +++++- src/services/webhooks.rs | 49 +- src/topic.rs | 251 ++ tests/tests.rs | 66 +- 411 files changed, 18926 insertions(+), 2523 deletions(-) delete mode 100644 docs/examples/account/list-logs.md delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/delete-key.md delete mode 100644 docs/examples/organization/get-key.md delete mode 100644 docs/examples/organization/list-keys.md delete mode 100644 docs/examples/organization/update-key.md delete mode 100644 docs/examples/users/list-logs.md delete mode 100644 src/enums/organization_key_scopes.rs delete mode 100644 src/models/dedicated_database_specification_pricing.rs delete mode 100644 src/models/dev_key.rs delete mode 100644 src/models/log.rs delete mode 100644 src/models/log_list.rs create mode 100644 src/topic.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index ed2831c..926c3be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.16.0] - TBD +## [0.20.0] - TBD ### Added - Initial release of Appwrite Rust SDK -- Full support for Appwrite API 2.0.0 +- Full support for Appwrite API 2.5.0 - Async/await support with tokio runtime - Built-in error handling with custom error types - File upload support with automatic chunking @@ -22,25 +22,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Automatic JSON serialization/deserialization ### Features -- Account service with 59 methods +- Account service with 71 methods - Activities service with 2 methods - Apps service with 22 methods -- Avatars service with 9 methods +- Avatars service with 11 methods - Backups service with 12 methods - Databases service with 71 methods - DocumentsDB service with 37 methods +- Domains service with 47 methods - Embeddings service with 1 methods - Functions service with 26 methods - Graphql service with 2 methods - Locale service with 8 methods -- Messaging service with 54 methods +- Messaging service with 56 methods - Mongo service with 31 methods - Mysql service with 34 methods -- Oauth2 service with 12 methods +- Oauth2 service with 13 methods - Organization service with 23 methods - Postgresql service with 37 methods - Presences service with 5 methods -- Project service with 105 methods +- Project service with 116 methods - Proxy service with 9 methods - Advisor service with 5 methods - Sites service with 25 methods @@ -48,8 +49,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - TablesDB service with 81 methods - Teams service with 18 methods - Tokens service with 5 methods -- Users service with 50 methods +- Users service with 53 methods - VectorsDB service with 36 methods +- Waf service with 13 methods - Webhooks service with 6 methods ### Services @@ -68,7 +70,6 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `list_identities()` - Get the list of identities for the currently logged in user. - `delete_identity()` - Delete an identity by its unique ID. -- `list_logs()` - 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. - `update_mfa()` - Enable or disable MFA on an account. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. @@ -89,6 +90,12 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_name()` - Update currently logged in user account name. +- `list_passkeys()` - Get the list of verified passkeys registered by the currently logged in user. +- `create_passkey()` - 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. +- `get_passkey()` - Get a verified passkey of the currently logged in user by its unique ID. +- `update_passkey()` - Rename a passkey of the currently logged in user. +- `delete_passkey()` - 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. +- `update_passkey_verification()` - 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. - `update_password()` - Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. - `update_phone()` - Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. - `get_prefs()` - Get the preferences as a key-value object for the currently logged in user. @@ -97,12 +104,30 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_recovery()` - 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. +- `create_recovery_otp()` - 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. + +- `update_recovery_otp()` - 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. + - `list_sessions()` - Get the list of active sessions across different devices for the currently logged in user. -- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. +- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. - `create_anonymous_session()` - Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). -- `create_email_password_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. +- `create_email_password_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 limits](https://appwrite.io/docs/authentication-security#limits). +- `create_id_token_session()` - 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). + - `update_magic_url_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `update_phone_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `create_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -122,7 +147,11 @@ A user is limited to 10 active sessions at a time by default. [Learn more about If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create 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). +- `create_passkey_token()` - 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. +- `update_passkey_token()` - 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. - `create_phone_token()` - 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 /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. 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). @@ -136,6 +165,12 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ - `update_email_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. - `update_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. +- `create_email_verification_otp()` - 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. + +- `update_email_verification_otp()` - 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. + - `create_phone_verification()` - Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. - `update_phone_verification()` - Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -197,9 +232,11 @@ You can use the color and background params to change the avatar colors. By defa When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. -- `get_photo()` - 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. +- `get_photo()` - Returns the best available profile photo for a user. The endpoint tries 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, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. +- `update_photo()` - 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. +- `delete_photo()` - 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. - `get_qr()` - 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. - `get_screenshot()` - Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -332,7 +369,7 @@ The Databases service allows you to create structured collections of documents, - `increment_document_attribute()` - Increment a specific attribute of a document by a given value. - `list_indexes()` - List indexes in the collection. - `create_index()` - Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. - `get_index()` - Get an index by its unique ID. - `delete_index()` - Delete an index. @@ -341,7 +378,7 @@ Attributes can be `key`, `fulltext`, and `unique`. - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -379,6 +416,127 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Domains + +- `list()` - List all domains registered for this project. This endpoint supports pagination. +- `create()` - 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. +- `get_price()` - Get the registration price for a domain name. +- `list_prices()` - 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. +- `get()` - Get a domain by its unique ID. +- `delete()` - 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. +- `update_nameservers()` - Update the registrar nameservers for the given domain. When nameservers are not provided, +the domain will be updated to use Appwrite nameservers. +- `verify_nameservers()` - 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. +- `get_preset_google_workspace()` - List Google Workspace DNS records. +- `create_preset_google_workspace()` - Add Google Workspace DNS records to the domain. This will create the required MX records +for Google Workspace email hosting. +- `get_preset_i_cloud()` - List iCloud DNS records. +- `create_preset_i_cloud()` - Add iCloud DNS records to the domain. This will create the required MX and SPF records +for using iCloud email services with your domain. +- `get_preset_mailgun()` - List Mailgun DNS records. +- `create_preset_mailgun()` - Add Mailgun DNS records to the domain. This endpoint will create the required DNS records +for Mailgun in the specified domain. +- `get_preset_outlook()` - List Outlook DNS records. +- `create_preset_outlook()` - Add Outlook DNS records to the domain. This will create the required MX records +for setting up Outlook email hosting for your domain. +- `get_preset_proton_mail()` - List ProtonMail DNS records. +- `create_preset_proton_mail()` - Add ProtonMail DNS records to the domain. This will create the required MX records +for using ProtonMail with your custom domain. +- `get_preset_zoho()` - List Zoho DNS records. +- `create_preset_zoho()` - Add Zoho Mail DNS records to the domain. This will create the required MX records +for setting up Zoho Mail on your domain. +- `list_records()` - List DNS records for a given domain. You can use this endpoint to list all the DNS records +associated with your domain. +- `create_record_a()` - 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. +- `update_record_a()` - 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. +- `create_record_aaaa()` - 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. +- `update_record_aaaa()` - 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. +- `create_record_alias()` - 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. +- `update_record_alias()` - 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. +- `create_record_caa()` - 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. +- `update_record_caa()` - 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. +- `create_record_cname()` - 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'. +- `update_record_cname()` - Update an existing CNAME record for the given domain. +- `create_record_https()` - 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. +- `update_record_https()` - 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. +- `create_record_mx()` - 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. +- `update_record_mx()` - Update an existing MX record for the given domain. +- `create_record_ns()` - 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. +- `update_record_ns()` - 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. +- `create_record_srv()` - 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. +- `update_record_srv()` - 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 +- `create_record_txt()` - 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. +- `update_record_txt()` - 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. +- `get_record()` - 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. +- `delete_record()` - Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record +from a specific domain. +- `update_team()` - 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. +- `get_transfer_status()` - Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. +- `get_zone()` - 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. +- `update_zone()` - 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. + #### Embeddings - `create_text_embeddings()` - Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. @@ -463,6 +621,8 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `create_apns_provider()` - Create a new Apple Push Notification service provider. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. +- `create_appwrite_provider()` - Create a new Appwrite push provider. +- `update_appwrite_provider()` - Update an Appwrite push provider by its unique ID. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `update_fcm_provider()` - Update a Firebase Cloud Messaging provider by its unique ID. @@ -509,7 +669,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -543,7 +703,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -584,6 +744,7 @@ The OAuth2 service allows you to authorize apps and issue standards-based OAuth2 - `create_device_authorization()` - Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. - `create_grant()` - Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. - `get_grant()` - Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. +- `introspect()` - 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. - `list_organizations()` - 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. - `create_par()` - Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. - `list_projects()` - List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. @@ -601,11 +762,6 @@ The Organization service allows you to manage organization-level projects. - `get_installation()` - Get an app installation on the organization by its unique ID. Any organization member can read installations. - `update_installation()` - Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. - `delete_installation()` - Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked. -- `list_keys()` - Get a list of all API keys from the current organization. -- `create_key()` - Create a new organization API key. -- `get_key()` - Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. -- `update_key()` - Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. -- `delete_key()` - Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - `list_memberships()` - Get a list of all memberships from the current organization. - `create_membership()` - 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. - `get_membership()` - Get a membership from the current organization by its unique ID. @@ -616,12 +772,19 @@ The Organization service allows you to manage organization-level projects. - `get_project()` - Get a project. - `update_project()` - Update a project by its unique ID. - `delete_project()` - Delete a project by its unique ID. +- `list_project_keys()` - Get a list of all API keys of a project in your organization. +- `create_ephemeral_project_key()` - Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + +You can also create a standard API key if you need a longer-lived key instead. +- `get_project_key()` - Get a project key by its unique ID. +- `update_project_key()` - Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. +- `delete_project_key()` - Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. #### Postgresql - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -675,6 +838,11 @@ The Project service allows you to manage all the projects in your Appwrite serve - `get()` - Get a project. - `delete()` - Delete a project. - `update_auth_method()` - Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. +- `list_environments()` - Get a list of all environments of the project. You can use the query params to filter your results. +- `create_environment()` - Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. +- `get_environment()` - Get an environment of the project by its unique ID. +- `update_environment()` - Update the name of an environment of the project. +- `delete_environment()` - Delete an environment of the project, with all of its resources and users. - `list_keys()` - Get a list of all API keys from the current project. - `create_ephemeral_key()` - Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. @@ -712,6 +880,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_gitlab()` - Update the project OAuth2 Gitlab configuration. - `update_o_auth2_google()` - Update the project OAuth2 Google configuration. - `update_o_auth2_hugging_face()` - Update the project OAuth2 Hugging Face configuration. +- `update_o_auth2_kakao()` - Update the project OAuth2 Kakao configuration. - `update_o_auth2_keycloak()` - Update the project OAuth2 Keycloak configuration. - `update_o_auth2_kick()` - Update the project OAuth2 Kick configuration. - `update_o_auth2_linkedin()` - Update the project OAuth2 Linkedin configuration. @@ -727,9 +896,11 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_slack()` - Update the project OAuth2 Slack configuration. - `update_o_auth2_spotify()` - Update the project OAuth2 Spotify configuration. - `update_o_auth2_stripe()` - Update the project OAuth2 Stripe configuration. +- `update_o_auth2_tik_tok()` - Update the project OAuth2 TikTok configuration. - `update_o_auth2_tradeshift()` - Update the project OAuth2 Tradeshift configuration. - `update_o_auth2_tradeshift_sandbox()` - Update the project OAuth2 Tradeshift Sandbox configuration. - `update_o_auth2_twitch()` - Update the project OAuth2 Twitch configuration. +- `update_o_auth2_webflow()` - Update the project OAuth2 Webflow configuration. - `update_o_auth2_word_press()` - Update the project OAuth2 WordPress configuration. - `update_o_auth2_x()` - Update the project OAuth2 X configuration. - `update_o_auth2_yahoo()` - Update the project OAuth2 Yahoo configuration. @@ -739,7 +910,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `get_o_auth2_provider()` - Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. - `list_platforms()` - Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. - `create_android_platform()` - Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. -- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. +- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. - `create_apple_platform()` - Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. - `update_apple_platform()` - Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. - `create_linux_platform()` - Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. @@ -757,11 +928,14 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_deny_free_email_policy()` - Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. - `update_membership_privacy_policy()` - Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. - `update_mfa_factors_policy()` - Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. +- `update_passkey_policy()` - 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. - `update_password_dictionary_policy()` - 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. - `update_password_history_policy()` - Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. - `update_password_personal_data_policy()` - Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. +- `update_password_pwned_policy()` - 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. +- `update_password_rotation_policy()` - 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. - `update_password_strength_policy()` - Update the password strength requirements for users in the project. - `update_session_alert_policy()` - Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. - `update_session_duration_policy()` - Update maximum duration how long sessions created within a project should stay active for. @@ -787,6 +961,8 @@ The Proxy Service allows you to configure actions for your domains beyond DNS co - `create_invalidation()` - Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. 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. - `list_rules()` - Get a list of all the proxy rules. You can use the query params to filter your results. - `create_api_rule()` - Create a new proxy rule for serving Appwrite's API on custom domain. @@ -877,7 +1053,7 @@ The TablesDB service allows you to create structured tables of columns, query an - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -946,6 +1122,8 @@ The TablesDB service allows you to create structured tables of columns, query an - `update_polygon_column()` - Update a polygon column. Changing the `default` value will not update already existing rows. - `create_relationship_column()` - Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). +- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + - `create_string_column()` - Create a string column. - `update_string_column()` - Update a string column. Changing the `default` value will not update already existing rows. @@ -964,11 +1142,9 @@ The TablesDB service allows you to create structured tables of columns, query an - `get_column()` - Get column by ID. - `delete_column()` - Deletes a column. -- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - - `list_indexes()` - List indexes on the table. - `create_index()` - Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. - `get_index()` - Get index by ID. - `delete_index()` - Delete an index. - `list_rows()` - Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -1041,13 +1217,12 @@ The Users service allows you to manage your project users. - `get()` - Get a user by its unique ID. - `delete()` - Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. - `update_email()` - Update the user email by its unique ID. -- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. 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. - `create_jwt()` - Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. - `update_labels()` - Update the user labels by its unique ID. Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. -- `list_logs()` - Get the user activity logs list by its unique ID. - `list_memberships()` - Get the user membership list by its unique ID. - `update_mfa()` - Enable or disable MFA on a user account. - `update_mfa()` - Enable or disable MFA on a user account. @@ -1063,6 +1238,10 @@ Labels can be used to grant access to resources. While teams are a way for user& - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `update_name()` - Update the user name by its unique ID. +- `list_passkeys()` - Get the list of verified passkeys registered by a user. +- `get_passkey()` - Get a verified passkey of a user by its unique ID. +- `update_passkey()` - Rename a passkey of a user. +- `delete_passkey()` - Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. - `update_password()` - Update the user password by its unique ID. - `update_phone()` - Update the user phone by its unique ID. - `get_prefs()` - Get the user preferences by its unique ID. @@ -1089,7 +1268,7 @@ If you want to generate a token for a custom authentication flow, use the [POST - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -1127,6 +1306,35 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Waf + +- `list_rules()` - List WAF rules for the current project. + +- `create_bypass_rule()` - 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. + +- `update_bypass_rule()` - 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. + +- `create_challenge_rule()` - 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. + +- `update_challenge_rule()` - 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. + +- `create_deny_rule()` - 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. + +- `update_deny_rule()` - 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. + +- `create_rate_limit_rule()` - 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. + +- `update_rate_limit_rule()` - 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. + +- `create_redirect_rule()` - 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. + +- `update_redirect_rule()` - 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. + +- `get_rule()` - Get a WAF rule by its ID. + +- `delete_rule()` - Delete a WAF rule. + + #### Webhooks The Webhooks service allows you to manage your project webhooks. - `list()` - Get a list of all webhooks belonging to the project. You can use the query params to filter your results. @@ -1149,7 +1357,6 @@ The Webhooks service allows you to manage your project webhooks. - `UserList` - Users List - `SessionList` - Sessions List - `IdentityList` - Identities List -- `LogList` - Logs List - `FileList` - Files List - `BucketList` - Buckets List - `ResourceTokenList` - Resource Tokens List @@ -1236,7 +1443,6 @@ The Webhooks service allows you to manage your project webhooks. - `Row` - Row - `Document` - Document - `Presence` - Presence -- `Log` - Log - `User` - User - `AlgoMd5` - AlgoMD5 - `AlgoSha` - AlgoSHA @@ -1245,6 +1451,7 @@ The Webhooks service allows you to manage your project webhooks. - `AlgoScrypt` - AlgoScrypt - `AlgoScryptModified` - AlgoScryptModified - `AlgoArgon2` - AlgoArgon2 +- `Account` - Account - `Preferences` - Preferences - `Session` - Session - `Identity` - Identity @@ -1271,7 +1478,6 @@ The Webhooks service allows you to manage your project webhooks. - `Webhook` - Webhook - `Key` - Key - `EphemeralKey` - Ephemeral Key -- `DevKey` - DevKey - `MockNumber` - Mock Number - `OAuth2Github` - OAuth2GitHub - `OAuth2Discord` - OAuth2Discord @@ -1288,6 +1494,7 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Yandex` - OAuth2Yandex - `OAuth2X` - OAuth2X - `OAuth2WordPress` - OAuth2WordPress +- `OAuth2Webflow` - OAuth2Webflow - `OAuth2Twitch` - OAuth2Twitch - `OAuth2Stripe` - OAuth2Stripe - `OAuth2Spotify` - OAuth2Spotify @@ -1317,11 +1524,15 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Apple` - OAuth2Apple - `OAuth2Microsoft` - OAuth2Microsoft - `OAuth2Resend` - OAuth2Resend +- `OAuth2TikTok` - OAuth2TikTok +- `OAuth2Kakao` - OAuth2Kakao - `OAuth2ProviderList` - OAuth2 Providers List - `PolicyPasswordDictionary` - Policy Password Dictionary - `PolicyPasswordHistory` - Policy Password History - `PolicyPasswordStrength` - Policy Password Strength - `PolicyPasswordPersonalData` - Policy Password Personal Data +- `PolicyPasswordPwned` - Policy Password Pwned +- `PolicyPasswordRotation` - Policy Password Rotation - `PolicySessionAlert` - Policy Session Alert - `PolicySessionDuration` - Policy Session Duration - `PolicySessionInvalidation` - Policy Session Invalidation @@ -1329,6 +1540,11 @@ The Webhooks service allows you to manage your project webhooks. - `PolicyUserLimit` - Policy User Limit - `PolicyMembershipPrivacy` - Policy Membership Privacy - `PolicyMfaFactors` - Policy MFA Factors +- `PolicyPasskey` - Policy Passkey +- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email +- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email +- `PolicyDenyFreeEmail` - Policy Deny Free Email +- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `PlatformWeb` - Platform Web - `PlatformApple` - Platform Apple - `PlatformAndroid` - Platform Android @@ -1347,6 +1563,10 @@ The Webhooks service allows you to manage your project webhooks. - `EmailTemplate` - EmailTemplate - `MfaChallenge` - MFA Challenge - `MfaChallengeSecret` - MFA Challenge Secret +- `TokenSecret` - Token Secret +- `Passkey` - Passkey +- `PasskeyChallenge` - Passkey Challenge +- `PasskeyList` - Passkeys List - `MfaRecoveryCodes` - MFA Recovery Codes - `MfaType` - MFAType - `MfaFactors` - MFAFactors @@ -1381,6 +1601,10 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseExecutionColumn` - ExecutionColumn - `DedicatedDatabaseRestoration` - Restoration - `DatabaseStatus` - Status +- `DnsRecord` - DNSRecord +- `Domain` - Domain +- `DomainPrice` - DomainPrice +- `DomainTransferStatus` - domainTransferStatus - `DedicatedDatabaseExtensions` - Extensions - `DedicatedDatabaseMember` - Member - `DedicatedDatabaseOperation` - Operation @@ -1390,10 +1614,6 @@ The Webhooks service allows you to manage your project webhooks. - `Organization` - Organization - `DedicatedDatabasePITRWindows` - PITRWindows - `BackupPolicy` - backup -- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email -- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email -- `PolicyDenyFreeEmail` - Policy Deny Free Email -- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `DedicatedDatabasePooler` - PoolerConfig - `PostgresExtension` - Postgres extension - `Program` - Program @@ -1401,7 +1621,6 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseRestorationList` - Dedicated database restorations list - `DedicatedDatabaseSpecification` - Specification - `DedicatedDatabaseSpecificationList` - SpecificationList -- `DedicatedDatabaseSpecificationPricing` - SpecificationPricing - `DatabaseStatusConnections` - Connections - `DatabaseStatusReplica` - Replica - `DatabaseStatusVolume` - Volume @@ -1419,8 +1638,15 @@ The Webhooks service allows you to manage your project webhooks. - `Oauth2DeviceAuthorization` - OAuth2 Device Authorization - `Oauth2PAR` - OAuth2 PAR - `Oauth2Token` - OAuth2 Token +- `Oauth2Introspection` - OAuth2 Introspection - `Oauth2Consent` - OAuth2 Consent - `Oauth2ConsentToken` - OAuth2 Consent Token +- `WafRuleBypass` - WafRuleBypass +- `WafRuleDeny` - WafRuleDeny +- `WafRuleChallenge` - WafRuleChallenge +- `WafRuleRateLimit` - WafRuleRateLimit +- `WafRuleRedirect` - WafRuleRedirect +- `WafRuleList` - WAF rule list - `Oauth2Project` - OAuth2 Project - `Oauth2Organization` - OAuth2 Organization - `Oauth2ProjectList` - OAuth2 accessible projects list @@ -1433,6 +1659,9 @@ The Webhooks service allows you to manage your project webhooks. - `BackupRestorationList` - Backup restoration list - `DatabaseMigrationList` - Database Migrations List - `DedicatedDatabaseList` - Dedicated databases list +- `DnsRecordsList` - DNS records list +- `DomainPricesList` - Domain prices list +- `DomainsList` - Domains list - `AppsList` - Apps list - `AppSecretList` - App secrets list - `AppScopeList` - App scopes list @@ -1453,4 +1682,4 @@ The Webhooks service allows you to manage your project webhooks. - File upload examples - Query builder documentation -[0.16.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.16.0 +[0.20.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.20.0 diff --git a/Cargo.toml b/Cargo.toml index b5198a4..784ba2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "appwrite" -version = "0.19.0" +version = "0.20.0" edition = "2021" rust-version = "1.83" authors = ["appwrite"] diff --git a/README.md b/README.md index 3b784e1..26523cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Appwrite Rust SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-rust.svg) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg) [![Crates.io](https://img.shields.io/crates/v/appwrite.svg)](https://crates.io/crates/appwrite) [![Documentation](https://docs.rs/appwrite/badge.svg)](https://docs.rs/appwrite) -**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-rust/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-rust/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 Rust 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) @@ -17,7 +17,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -appwrite = "0.19.0" +appwrite = "0.20.0" tokio = { version = "1.48", features = ["full"] } ``` diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index a6f2987..6314ff5 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent_token( + account.delete_consent_token( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index 084f1c6..c850bcd 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent( + account.delete_consent( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 8f332bf..0000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,23 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Account; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_session(""); // The user session to authenticate with - - let account = Account::new(&client); - - let result = account.list_logs( - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index 320dac4..8abf001 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_installation( + apps.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index 1d3bf37..2b3c9ae 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_key( + apps.delete_key( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index 1fa363c..86ba5da 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_secret( + apps.delete_secret( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index febc173..dc71045 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_tokens( + apps.delete_tokens( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index 84d8cfd..ab57e98 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete( + apps.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index d75868a..5929752 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_archive( + backups.delete_archive( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index 05e44f4..2368cc2 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_policy( + backups.delete_policy( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index f469178..249a02f 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index b7389d9..8e7aeef 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DatabasesIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 2d75876..7642b78 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 6ef035f..e37391a 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1c60d5c..5154b92 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index 2b7534c..3ace295 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DocumentsDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index be2ad02..f2807ca 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index d6ba165..40e58ed 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 8f945bb..de4f2e5 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let embeddings = Embeddings::new(&client); let result = embeddings.create_text_embeddings( - vec![], + vec!["Appwrite helps developers build applications.".into(), "Find documents with semantic search.".into()], Some(appwrite::enums::EmbeddingModel::NomicEmbedText) // optional ).await?; diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 2a28b83..0746b1e 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = messaging.create_twilio_provider( "", "", - Some("+12065550100"), // optional + Some(""), // optional Some(""), // optional Some(""), // optional Some(false) // optional diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md index 9114d69..05d5d23 100644 --- a/docs/examples/mongo/delete-backup-policy.md +++ b/docs/examples/mongo/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup_policy( + mongo.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md index d596d40..b992f13 100644 --- a/docs/examples/mongo/delete-backup.md +++ b/docs/examples/mongo/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup( + mongo.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md index 777f263..3f9734f 100644 --- a/docs/examples/mongo/delete.md +++ b/docs/examples/mongo/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete( + mongo.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md index 39ae07e..2e859af 100644 --- a/docs/examples/mysql/delete-backup-policy.md +++ b/docs/examples/mysql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup_policy( + mysql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md index 2e0b931..40b6302 100644 --- a/docs/examples/mysql/delete-backup.md +++ b/docs/examples/mysql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup( + mysql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md index db5d332..ab8b4b9 100644 --- a/docs/examples/mysql/delete.md +++ b/docs/examples/mysql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete( + mysql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index ff39bf6..ee6c153 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 2593e9b..45ada9f 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index db2c875..3a93e0b 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index c894372..a026965 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index a208289..6bf1198 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 3e344a2..f334c66 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index eecf973..8bc0d41 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some("https://example.com"), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index fbd475d..8270c93 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index c440370..6f32686 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 30c6e9f..d21afc2 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index a303692..645c41d 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 9469837..638b47e 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 5ec24d8..0000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.create_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index d4cb99d..af3dc97 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let organization = Organization::new(&client); - let result = organization.delete_installation( + organization.delete_installation( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md deleted file mode 100644 index 34a1e1b..0000000 --- a/docs/examples/organization/delete-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - organization.delete_key( - "" - ).await?; - - Ok(()) -} -``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md deleted file mode 100644 index 2d01434..0000000 --- a/docs/examples/organization/get-key.md +++ /dev/null @@ -1,22 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.get_key( - "" - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md deleted file mode 100644 index 1466645..0000000 --- a/docs/examples/organization/list-keys.md +++ /dev/null @@ -1,23 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.list_keys( - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index a798005..0000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.update_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md index 1362635..4eeef55 100644 --- a/docs/examples/postgresql/delete-backup-policy.md +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup_policy( + postgresql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md index f30ba45..f5ba8fd 100644 --- a/docs/examples/postgresql/delete-backup.md +++ b/docs/examples/postgresql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup( + postgresql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md index 4d9207e..8a966ce 100644 --- a/docs/examples/postgresql/delete.md +++ b/docs/examples/postgresql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete( + postgresql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 93d1dc4..357e4d6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.create_ephemeral_key( - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], 600 ).await?; diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index cb5f2ce..a62073f 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); project.create_smtp_test( - vec![] + vec!["recipient@example.com".into()] ).await?; Ok(()) diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 12b0282..1c6148a 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = project.update_key( "", "", - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], Some("2020-10-15T06:38:00.000+00:00") // optional ).await?; diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index 541993e..e9b0ea4 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.update_labels( - vec![] + vec!["production".into()] ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index f96eb6e..4f8dbdd 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,8 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_kakao( Some(""), // optional Some(""), // optional - Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 7e5d915..d837d4e 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let sites = Sites::new(&client); - let result = sites.delete_log( + sites.delete_log( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 409d88d..725a771 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::TablesDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index b5722c4..86e0b5c 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 36606d6..d3ebd3d 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let tables_db = TablesDB::new(&client); - let result = tables_db.delete_migration( + tables_db.delete_migration( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 92520ae..e1fe9bc 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.delete_rows( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index ba84a60..94e26a9 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.upsert_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index bb83298..14400af 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = teams.create_membership( "", - vec![], + vec!["editor".into()], Some("email@example.com"), // optional Some(""), // optional Some("+12065550100"), // optional diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index b635b14..6af98a5 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let teams = Teams::new(&client); - let result = teams.delete_installation( + teams.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 6c6d0d7..512671a 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = teams.update_membership( "", "", - vec![] + vec!["editor".into()] ).await?; let _ = result; diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md deleted file mode 100644 index 6f5b333..0000000 --- a/docs/examples/users/list-logs.md +++ /dev/null @@ -1,24 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Users; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let users = Users::new(&client); - - let result = users.list_logs( - "", - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 00922e3..9305ebb 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = users.update_labels( "", - vec![] + vec!["subscriber".into()] ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index 1010288..f539c40 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - 1, + 4, Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index d2aff1f..b8c30b6 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index 02d30e2..f686c4e 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::VectorsDBIndexType::HnswEuclidean, - vec![], + vec!["embeddings".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index cc1aaca..bc8db2b 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_operations( "", - Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"name":"Walter O'Brien"}})]) // optional + Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}}})]) // optional ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index a69a6a7..fc80819 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 86309ba..4256276 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - Some(1), // optional + Some(4), // optional Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index c556118..5f120e9 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index a14a6c1..2862ee9 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "https://example.com/webhook", "", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 73d636d..407ea25 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "", "https://example.com/webhook", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/src/client.rs b/src/client.rs index 946094f..7d44b79 100644 --- a/src/client.rs +++ b/src/client.rs @@ -59,6 +59,12 @@ impl Default for UploadOptions { } } +#[derive(Debug, Clone, Copy)] +enum ResponseFormat { + Json, + Text, +} + /// Appwrite client for making API requests #[derive(Debug, Clone)] pub struct Client { @@ -91,11 +97,11 @@ impl Client { /// Create a new Appwrite client pub fn new() -> Self { let mut headers = HeaderMap::new(); - headers.insert("X-Appwrite-Response-Format", "2.0.0".parse().unwrap()); + headers.insert("X-Appwrite-Response-Format", "2.5.0".parse().unwrap()); headers.insert( "user-agent", format!( - "AppwriteRustSDK/0.19.0 ({}; {})", + "AppwriteRustSDK/0.20.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH ) @@ -105,7 +111,7 @@ impl Client { headers.insert("x-sdk-name", "Rust".parse().unwrap()); headers.insert("x-sdk-platform", "server".parse().unwrap()); headers.insert("x-sdk-language", "rust".parse().unwrap()); - headers.insert("x-sdk-version", "0.19.0".parse().unwrap()); + headers.insert("x-sdk-version", "0.20.0".parse().unwrap()); let config = Config { endpoint: "https://cloud.appwrite.io/v1".to_string(), @@ -289,21 +295,6 @@ impl Client { self.clone() } - /// Set DevKey - /// - /// Your secret dev API key - pub fn set_dev_key>(&self, value: S) -> Self { - let value = value.into(); - self.state.rcu(|state| { - let mut next = (**state).clone(); - next.config - .headers - .insert("x-appwrite-dev-key", value.clone().parse().unwrap()); - Arc::new(next) - }); - self.clone() - } - /// Set Cookie /// /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -554,36 +545,27 @@ impl Client { headers: Option>, params: Option>, ) -> Result { - let response = self.request(method, path, headers, params).await?; - self.handle_response(response).await - } - - /// Make an API call that returns a plain-text body as a UTF-8 string - pub async fn call_text( - &self, - method: Method, - path: &str, - headers: Option>, - params: Option>, - ) -> Result { - let response = self.request(method, path, headers, params).await?; - if response.status().is_success() { - return Ok(response.text().await?); - } - self.handle_response::(response) + self.send(method, path, headers, params, ResponseFormat::Json) .await - .map(|_| String::new()) } - async fn request( + async fn send( &self, method: Method, path: &str, headers: Option>, params: Option>, - ) -> Result { + format: ResponseFormat, + ) -> Result { let state = self.state.load_full(); let url = format!("{}{}", state.config.endpoint, path); + let is_multipart = method != Method::GET + && headers.as_ref().is_some_and(|headers| { + headers.iter().any(|(key, value)| { + key.eq_ignore_ascii_case("content-type") + && value.eq_ignore_ascii_case("multipart/form-data") + }) + }); let mut request_builder; if let Some(params) = params { @@ -600,21 +582,36 @@ impl Client { request_builder = state.http.request(method.clone(), url_with_params); } else { request_builder = state.http.request(method.clone(), &url); - request_builder = request_builder.json(¶ms); + if is_multipart { + let mut form = multipart::Form::new(); + for (key, value) in Self::flatten_multipart_params(¶ms, "") { + form = form.text(key, value); + } + request_builder = request_builder.multipart(form); + } else { + request_builder = request_builder.json(¶ms); + } } } else { request_builder = state.http.request(method.clone(), &url); } - request_builder = request_builder.headers(state.config.headers.clone()); + let mut default_headers = state.config.headers.clone(); + if is_multipart { + default_headers.remove("content-type"); + } + request_builder = request_builder.headers(default_headers); if let Some(custom_headers) = headers { for (key, value) in custom_headers { - request_builder = request_builder.header(key, value); + if !is_multipart || !key.eq_ignore_ascii_case("content-type") { + request_builder = request_builder.header(key, value); + } } } - Ok(request_builder.send().await?) + let response = request_builder.send().await?; + self.handle_response(response, format).await } /// Make an API call that returns a location/redirect URL (for webAuth endpoints) @@ -801,7 +798,19 @@ impl Client { } } - /// Upload a file + /// Make an API call that returns a plain-text body as a UTF-8 string + pub async fn call_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: Option>, + ) -> Result { + self.send(method, path, headers, params, ResponseFormat::Text) + .await + } + + /// Upload a file with POST pub async fn file_upload( &self, path: &str, @@ -824,7 +833,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method - #[allow(clippy::too_many_arguments)] pub async fn upload( &self, method: Method, @@ -851,7 +859,69 @@ impl Client { .await } - /// Upload a file with progress callback + /// Upload a file in one request whatever the configured chunk size, for + /// endpoints that do not accept chunked uploads + pub async fn single_upload( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) + .await + } + + /// Upload a file with POST and return the plain-text response body + pub async fn file_upload_text( + &self, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + self.upload_text(Method::POST, path, headers, params, param_name, input_file) + .await + } + + /// Upload a file with the endpoint's HTTP method and return the plain-text response body + pub async fn upload_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Text, + ) + .await + } + + /// Upload a file with POST and a progress callback pub async fn file_upload_with_progress( &self, path: &str, @@ -877,7 +947,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method and a progress callback - #[allow(clippy::too_many_arguments)] pub async fn upload_with_progress( &self, method: Method, @@ -902,7 +971,15 @@ impl Client { let url = format!("{}{}", state.config.endpoint, path); let result = self - .single_file_upload(method, &url, headers, params, param_name, &input_file) + .single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) .await?; if let Some(callback) = &options.on_progress { @@ -929,22 +1006,6 @@ impl Client { .await } - /// Upload a file in one request, whatever the configured chunk size, for - /// endpoints that do not accept chunked uploads - pub(crate) async fn single_upload( - &self, - method: Method, - path: &str, - headers: Option>, - params: HashMap, - param_name: &str, - input_file: InputFile, - ) -> Result { - let url = format!("{}{}", self.state.load_full().config.endpoint, path); - self.single_file_upload(method, &url, headers, params, param_name, &input_file) - .await - } - async fn single_file_upload( &self, method: Method, @@ -953,6 +1014,7 @@ impl Client { params: HashMap, param_name: &str, input_file: &InputFile, + format: ResponseFormat, ) -> Result { let state = self.state.load_full(); let mut form = multipart::Form::new(); @@ -997,10 +1059,9 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, format).await } - #[allow(clippy::too_many_arguments)] async fn chunked_file_upload_with_progress( &self, method: Method, @@ -1099,6 +1160,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1106,7 +1168,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1160,6 +1221,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1167,7 +1229,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1279,10 +1340,14 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, ResponseFormat::Json).await } - async fn handle_response(&self, response: Response) -> Result { + async fn handle_response( + &self, + response: Response, + format: ResponseFormat, + ) -> Result { let status = response.status(); let content_type = response .headers() @@ -1295,6 +1360,19 @@ impl Client { if status.is_success() { let bytes = response.bytes().await?; + if let ResponseFormat::Text = format { + let text = String::from_utf8(bytes.to_vec()).map_err(|e| { + AppwriteError::new( + 0, + format!("Invalid UTF-8 response: {}", e), + None, + String::from_utf8_lossy(e.as_bytes()).to_string(), + ) + })?; + + return Ok(serde_json::from_value(Value::String(text))?); + } + if !content_type.is_empty() && !content_type.starts_with("application/json") && !bytes.is_empty() diff --git a/src/enums/billing_plan_group.rs b/src/enums/billing_plan_group.rs index 9557243..e8b9ed3 100644 --- a/src/enums/billing_plan_group.rs +++ b/src/enums/billing_plan_group.rs @@ -2,10 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum BillingPlanGroup { - #[serde(rename = "starter")] - #[default] - Starter, #[serde(rename = "free")] + #[default] Free, #[serde(rename = "start")] Start, @@ -19,7 +17,6 @@ impl BillingPlanGroup { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { - BillingPlanGroup::Starter => "starter", BillingPlanGroup::Free => "free", BillingPlanGroup::Start => "start", BillingPlanGroup::Pro => "pro", diff --git a/src/enums/execution_method.rs b/src/enums/execution_method.rs index 6764169..5dc4639 100644 --- a/src/enums/execution_method.rs +++ b/src/enums/execution_method.rs @@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ExecutionMethod { #[serde(rename = "GET")] - #[default] GET, #[serde(rename = "POST")] + #[default] POST, #[serde(rename = "PUT")] PUT, diff --git a/src/enums/image_gravity.rs b/src/enums/image_gravity.rs index 202aa5e..5114a01 100644 --- a/src/enums/image_gravity.rs +++ b/src/enums/image_gravity.rs @@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ImageGravity { + #[serde(rename = "auto")] + Auto, #[serde(rename = "center")] #[default] Center, @@ -21,14 +23,13 @@ pub enum ImageGravity { Bottom, #[serde(rename = "bottom-right")] BottomRight, - #[serde(rename = "auto")] - Auto, } impl ImageGravity { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { + ImageGravity::Auto => "auto", ImageGravity::Center => "center", ImageGravity::TopLeft => "top-left", ImageGravity::Top => "top", @@ -38,7 +39,6 @@ impl ImageGravity { ImageGravity::BottomLeft => "bottom-left", ImageGravity::Bottom => "bottom", ImageGravity::BottomRight => "bottom-right", - ImageGravity::Auto => "auto", } } } diff --git a/src/enums/mod.rs b/src/enums/mod.rs index 91c4db1..58377e5 100644 --- a/src/enums/mod.rs +++ b/src/enums/mod.rs @@ -54,8 +54,6 @@ pub mod message_priority; pub use message_priority::MessagePriority; pub mod smtp_encryption; pub use smtp_encryption::SmtpEncryption; -pub mod organization_key_scopes; -pub use organization_key_scopes::OrganizationKeyScopes; pub mod region; pub use region::Region; pub mod project_auth_method_id; diff --git a/src/enums/organization_key_scopes.rs b/src/enums/organization_key_scopes.rs deleted file mode 100644 index 7844c9b..0000000 --- a/src/enums/organization_key_scopes.rs +++ /dev/null @@ -1,72 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] -pub enum OrganizationKeyScopes { - #[serde(rename = "projects.read")] - #[default] - ProjectsRead, - #[serde(rename = "projects.write")] - ProjectsWrite, - #[serde(rename = "devKeys.read")] - DevKeysRead, - #[serde(rename = "devKeys.write")] - DevKeysWrite, - #[serde(rename = "organization.keys.read")] - OrganizationKeysRead, - #[serde(rename = "organization.keys.write")] - OrganizationKeysWrite, - #[serde(rename = "organization.installations.read")] - OrganizationInstallationsRead, - #[serde(rename = "organization.installations.write")] - OrganizationInstallationsWrite, - #[serde(rename = "organization.memberships.read")] - OrganizationMembershipsRead, - #[serde(rename = "organization.memberships.write")] - OrganizationMembershipsWrite, - #[serde(rename = "organization.read")] - OrganizationRead, - #[serde(rename = "organization.write")] - OrganizationWrite, - #[serde(rename = "domains.read")] - DomainsRead, - #[serde(rename = "domains.write")] - DomainsWrite, - #[serde(rename = "keys.read")] - KeysRead, - #[serde(rename = "keys.write")] - KeysWrite, -} - -impl OrganizationKeyScopes { - /// Get the string value of the enum - pub fn as_str(&self) -> &str { - match self { - OrganizationKeyScopes::ProjectsRead => "projects.read", - OrganizationKeyScopes::ProjectsWrite => "projects.write", - OrganizationKeyScopes::DevKeysRead => "devKeys.read", - OrganizationKeyScopes::DevKeysWrite => "devKeys.write", - OrganizationKeyScopes::OrganizationKeysRead => "organization.keys.read", - OrganizationKeyScopes::OrganizationKeysWrite => "organization.keys.write", - OrganizationKeyScopes::OrganizationInstallationsRead => { - "organization.installations.read" - } - OrganizationKeyScopes::OrganizationInstallationsWrite => { - "organization.installations.write" - } - OrganizationKeyScopes::OrganizationMembershipsRead => "organization.memberships.read", - OrganizationKeyScopes::OrganizationMembershipsWrite => "organization.memberships.write", - OrganizationKeyScopes::OrganizationRead => "organization.read", - OrganizationKeyScopes::OrganizationWrite => "organization.write", - OrganizationKeyScopes::DomainsRead => "domains.read", - OrganizationKeyScopes::DomainsWrite => "domains.write", - OrganizationKeyScopes::KeysRead => "keys.read", - OrganizationKeyScopes::KeysWrite => "keys.write", - } - } -} - -impl std::fmt::Display for OrganizationKeyScopes { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.as_str()) - } -} diff --git a/src/lib.rs b/src/lib.rs index 25914d9..b9f7ed2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```toml //! [dependencies] -//! appwrite = "0.19.0" +//! appwrite = "0.20.0" //! ``` //! //! ## Usage @@ -41,6 +41,7 @@ pub mod operator; pub mod permission; pub mod query; pub mod role; +pub mod topic; // Re-export commonly used types pub use client::Client; @@ -51,7 +52,7 @@ pub use input_file::InputFile; pub type Result = std::result::Result; /// SDK version -pub const VERSION: &str = "0.19.0"; +pub const VERSION: &str = "0.20.0"; /// SDK name pub const SDK_NAME: &str = "Rust"; diff --git a/src/models/activity_event.rs b/src/models/activity_event.rs index 5590142..b488871 100644 --- a/src/models/activity_event.rs +++ b/src/models/activity_event.rs @@ -8,93 +8,238 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEvent { /// Event ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Actor type. #[serde(rename = "actorType")] + #[serde(default = "default_actor_type")] pub actor_type: String, /// Actor ID. #[serde(rename = "actorId")] + #[serde(default = "default_actor_id")] pub actor_id: String, /// Actor Email. #[serde(rename = "actorEmail")] + #[serde(default = "default_actor_email")] pub actor_email: String, /// Actor Name. #[serde(rename = "actorName")] + #[serde(default = "default_actor_name")] pub actor_name: String, /// Resource parent. #[serde(rename = "resourceParent")] + #[serde(default = "default_resource_parent")] pub resource_parent: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource. #[serde(rename = "resource")] + #[serde(default = "default_resource")] pub resource: String, /// Event name. #[serde(rename = "event")] + #[serde(default = "default_event")] pub event: String, /// User agent. #[serde(rename = "userAgent")] + #[serde(default = "default_user_agent")] pub user_agent: String, /// IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// API mode when event triggered. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Location. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// City name. #[serde(rename = "city")] + #[serde(default = "default_city")] pub city: String, /// Region/state chain. #[serde(rename = "subdivisions")] + #[serde(default = "default_subdivisions")] pub subdivisions: String, /// Internet service provider. #[serde(rename = "isp")] + #[serde(default = "default_isp")] pub isp: String, /// Autonomous System Number (ASN). #[serde(rename = "autonomousSystemNumber")] + #[serde(default = "default_autonomous_system_number")] pub autonomous_system_number: String, /// Organization that owns the ASN. #[serde(rename = "autonomousSystemOrganization")] + #[serde(default = "default_autonomous_system_organization")] pub autonomous_system_organization: String, /// Connection type (e.g. cable, cellular, corporate). #[serde(rename = "connectionType")] + #[serde(default = "default_connection_type")] pub connection_type: String, /// User type (e.g. residential, business, hosting). #[serde(rename = "connectionUsageType")] + #[serde(default = "default_connection_usage_type")] pub connection_usage_type: String, /// Registered organization of the IP. #[serde(rename = "connectionOrganization")] + #[serde(default = "default_connection_organization")] pub connection_organization: String, /// Log creation date in ISO 8601 format. #[serde(rename = "time")] + #[serde(default = "default_time")] pub time: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Hostname. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Name of the SDK that triggered the event. #[serde(rename = "sdk")] + #[serde(default = "default_sdk")] pub sdk: String, /// Version of the SDK that triggered the event. #[serde(rename = "sdkVersion")] + #[serde(default = "default_sdk_version")] pub sdk_version: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_actor_type() -> String { + "".to_string() +} + +fn default_actor_id() -> String { + "".to_string() +} + +fn default_actor_email() -> String { + "".to_string() +} + +fn default_actor_name() -> String { + "".to_string() +} + +fn default_resource_parent() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource() -> String { + "".to_string() +} + +fn default_event() -> String { + "".to_string() +} + +fn default_user_agent() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_mode() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_city() -> String { + "".to_string() +} + +fn default_subdivisions() -> String { + "".to_string() +} + +fn default_isp() -> String { + "".to_string() +} + +fn default_autonomous_system_number() -> String { + "".to_string() +} + +fn default_autonomous_system_organization() -> String { + "".to_string() +} + +fn default_connection_type() -> String { + "".to_string() +} + +fn default_connection_usage_type() -> String { + "".to_string() +} + +fn default_connection_organization() -> String { + "".to_string() +} + +fn default_time() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_sdk() -> String { + "".to_string() +} + +fn default_sdk_version() -> String { + "".to_string() +} + impl ActivityEvent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/activity_event_list.rs b/src/models/activity_event_list.rs index a83d557..ff7cf56 100644 --- a/src/models/activity_event_list.rs +++ b/src/models/activity_event_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEventList { /// Total number of events that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ActivityEventList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/additional_resource.rs b/src/models/additional_resource.rs index bf02523..8f5d252 100644 --- a/src/models/additional_resource.rs +++ b/src/models/additional_resource.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct AdditionalResource { /// Resource name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Resource unit #[serde(rename = "unit")] + #[serde(default = "default_unit")] pub unit: String, /// Price currency #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_unit() -> String { + "".to_string() +} + +fn default_currency() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl AdditionalResource { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/algo_argon2.rs b/src/models/algo_argon2.rs index c4e4c7e..490a220 100644 --- a/src/models/algo_argon2.rs +++ b/src/models/algo_argon2.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoArgon2 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Memory used to compute hash. #[serde(rename = "memoryCost")] + #[serde(default = "default_memory_cost")] pub memory_cost: i64, /// Amount of time consumed to compute hash #[serde(rename = "timeCost")] + #[serde(default = "default_time_cost")] pub time_cost: i64, /// Number of threads used to compute hash. #[serde(rename = "threads")] + #[serde(default = "default_threads")] pub threads: i64, } +fn default_type() -> String { + "argon2".to_string() +} + +fn default_memory_cost() -> i64 { + 0 +} + +fn default_time_cost() -> i64 { + 0 +} + +fn default_threads() -> i64 { + 0 +} + impl AlgoArgon2 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_bcrypt.rs b/src/models/algo_bcrypt.rs index acbd333..93c307f 100644 --- a/src/models/algo_bcrypt.rs +++ b/src/models/algo_bcrypt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoBcrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "bcrypt".to_string() +} + impl AlgoBcrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_md5.rs b/src/models/algo_md5.rs index babd088..3f75ba8 100644 --- a/src/models/algo_md5.rs +++ b/src/models/algo_md5.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoMd5 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "md5".to_string() +} + impl AlgoMd5 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_phpass.rs b/src/models/algo_phpass.rs index 8227738..0a9f876 100644 --- a/src/models/algo_phpass.rs +++ b/src/models/algo_phpass.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoPhpass { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "phpass".to_string() +} + impl AlgoPhpass { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt.rs b/src/models/algo_scrypt.rs index 86a424a..18c4bce 100644 --- a/src/models/algo_scrypt.rs +++ b/src/models/algo_scrypt.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// CPU complexity of computed hash. #[serde(rename = "costCpu")] + #[serde(default = "default_cost_cpu")] pub cost_cpu: i64, /// Memory complexity of computed hash. #[serde(rename = "costMemory")] + #[serde(default = "default_cost_memory")] pub cost_memory: i64, /// Parallelization of computed hash. #[serde(rename = "costParallel")] + #[serde(default = "default_cost_parallel")] pub cost_parallel: i64, /// Length used to compute hash. #[serde(rename = "length")] + #[serde(default = "default_length")] pub length: i64, } +fn default_type() -> String { + "scrypt".to_string() +} + +fn default_cost_cpu() -> i64 { + 8 +} + +fn default_cost_memory() -> i64 { + 14 +} + +fn default_cost_parallel() -> i64 { + 1 +} + +fn default_length() -> i64 { + 64 +} + impl AlgoScrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt_modified.rs b/src/models/algo_scrypt_modified.rs index 3722ebd..35cd10c 100644 --- a/src/models/algo_scrypt_modified.rs +++ b/src/models/algo_scrypt_modified.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScryptModified { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Salt used to compute hash. #[serde(rename = "salt")] + #[serde(default = "default_salt")] pub salt: String, /// Separator used to compute hash. #[serde(rename = "saltSeparator")] + #[serde(default = "default_salt_separator")] pub salt_separator: String, /// Key used to compute hash. #[serde(rename = "signerKey")] + #[serde(default = "default_signer_key")] pub signer_key: String, } +fn default_type() -> String { + "scryptMod".to_string() +} + +fn default_salt() -> String { + "".to_string() +} + +fn default_salt_separator() -> String { + "".to_string() +} + +fn default_signer_key() -> String { + "".to_string() +} + impl AlgoScryptModified { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_sha.rs b/src/models/algo_sha.rs index e8aa8fb..f3af46d 100644 --- a/src/models/algo_sha.rs +++ b/src/models/algo_sha.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoSha { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "sha".to_string() +} + impl AlgoSha { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/app.rs b/src/models/app.rs index 35791b2..3ed9196 100644 --- a/src/models/app.rs +++ b/src/models/app.rs @@ -8,95 +8,225 @@ use serde::{Deserialize, Serialize}; pub struct App { /// App ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Application description shown to users during OAuth2 consent. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Application homepage URL shown to users during OAuth2 consent. #[serde(rename = "clientUri")] + #[serde(default = "default_client_uri")] pub client_uri: String, /// Application logo URL shown to users during OAuth2 consent. #[serde(rename = "logoUri")] + #[serde(default = "default_logo_uri")] pub logo_uri: String, /// Application privacy policy URL shown to users during OAuth2 consent. #[serde(rename = "privacyPolicyUrl")] + #[serde(default = "default_privacy_policy_url")] pub privacy_policy_url: String, /// Application terms of service URL shown to users during OAuth2 consent. #[serde(rename = "termsUrl")] + #[serde(default = "default_terms_url")] pub terms_url: String, /// Application support or security contact emails. #[serde(rename = "contacts")] + #[serde(default = "default_contacts")] pub contacts: Vec, /// Application tagline shown to users during OAuth2 consent. #[serde(rename = "tagline")] + #[serde(default = "default_tagline")] pub tagline: String, /// Application tags shown to users during OAuth2 consent. #[serde(rename = "tags")] + #[serde(default = "default_tags")] pub tags: Vec, /// Application labels. Read-only for clients; only a server SDK using a /// project API key can update them. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Application image URLs shown to users during OAuth2 consent. #[serde(rename = "images")] + #[serde(default = "default_images")] pub images: Vec, /// Application support URL shown to users during OAuth2 consent. #[serde(rename = "supportUrl")] + #[serde(default = "default_support_url")] pub support_url: String, /// Application data deletion URL shown to users during OAuth2 consent. #[serde(rename = "dataDeletionUrl")] + #[serde(default = "default_data_deletion_url")] pub data_deletion_url: String, /// List of authorized redirect URIs. These URIs can be used to redirect users /// after they authenticate. #[serde(rename = "redirectUris")] + #[serde(default = "default_redirect_uris")] pub redirect_uris: Vec, /// List of authorized post-logout redirect URIs for OpenID Connect /// RP-Initiated Logout. The logout endpoint only redirects users to URIs in /// this list after ending their session. #[serde(rename = "postLogoutRedirectUris")] + #[serde(default = "default_post_logout_redirect_uris")] pub post_logout_redirect_uris: Vec, /// Whether the app is enabled or not. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot /// keep a client secret (PKCE required); `confidential` for server-side /// clients that authenticate with a client secret. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Whether this client may use the OAuth2 Device Authorization Grant (RFC /// 8628). #[serde(rename = "deviceFlow")] + #[serde(default = "default_device_flow")] pub device_flow: bool, /// ID of team that owns the application, if owned by team. Otherwise, user ID /// will be used. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// ID of user who owns the application, if owned by user. Otherwise, team ID /// will be used. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Scopes the application requests when installed on a team. /// Organization-level and project-level scopes only. #[serde(rename = "installationScopes")] + #[serde(default = "default_installation_scopes")] pub installation_scopes: Vec, /// URL users are redirected to after creating or updating an installation of /// this application. Empty for no redirect. #[serde(rename = "installationRedirectUrl")] + #[serde(default = "default_installation_redirect_url")] pub installation_redirect_url: String, /// List of application secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_client_uri() -> String { + "".to_string() +} + +fn default_logo_uri() -> String { + "".to_string() +} + +fn default_privacy_policy_url() -> String { + "".to_string() +} + +fn default_terms_url() -> String { + "".to_string() +} + +fn default_contacts() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tagline() -> String { + "".to_string() +} + +fn default_tags() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_images() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_support_url() -> String { + "".to_string() +} + +fn default_data_deletion_url() -> String { + "".to_string() +} + +fn default_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_post_logout_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "confidential".to_string() +} + +fn default_device_flow() -> bool { + false +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_installation_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_installation_redirect_url() -> String { + "".to_string() +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl App { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation.rs b/src/models/app_installation.rs index 7ad4193..970ba93 100644 --- a/src/models/app_installation.rs +++ b/src/models/app_installation.rs @@ -8,34 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallation { /// Installation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Installation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Installation update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the installed application. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// ID of the team the application is installed on. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Scopes granted to the application. Snapshot of the application's /// installation scopes taken when the installation was created or last /// updated. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Authorization details granted to the application. Rich authorization /// request (RFC 9396) style entries; the Appwrite Console stores authorized /// project IDs here. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: Vec, /// ID of the user who created the installation. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the installation. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time an access token was last issued for the installation in ISO 8601 /// format. Null if never used. @@ -44,6 +53,42 @@ pub struct AppInstallation { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppInstallation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation_list.rs b/src/models/app_installation_list.rs index aa427f0..69c156a 100644 --- a/src/models/app_installation_list.rs +++ b/src/models/app_installation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallationList { /// Total number of installations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of installations. #[serde(rename = "installations")] + #[serde(default = "default_installations")] pub installations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_installations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppInstallationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_key.rs b/src/models/app_key.rs index cbfbbd0..4902670 100644 --- a/src/models/app_key.rs +++ b/src/models/app_key.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct AppKey { /// App key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App key creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App key update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this app key belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// App key secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the app key secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the app key. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the app key. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the app key was last used for authentication in ISO 8601 format. Null /// if never used. @@ -37,6 +45,38 @@ pub struct AppKey { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_key_list.rs b/src/models/app_key_list.rs index 232fa6f..d9ca8bb 100644 --- a/src/models/app_key_list.rs +++ b/src/models/app_key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppKeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppKeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_scope.rs b/src/models/app_scope.rs index 7f14082..fcdf744 100644 --- a/src/models/app_scope.rs +++ b/src/models/app_scope.rs @@ -8,23 +8,48 @@ use serde::{Deserialize, Serialize}; pub struct AppScope { /// Scope value as requested by apps. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Human-readable description of what the scope grants. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// What the scope grants access to. One of `account`, `project`, or /// `organization`. Only `project` and `organization` scopes are installable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Scope category, used to group scopes on consent and installation screens. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, /// Whether the scope is deprecated. Deprecated scopes can still be requested /// but should not be offered for new grants. #[serde(rename = "deprecated")] + #[serde(default = "default_deprecated")] pub deprecated: bool, } +fn default_value() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + +fn default_deprecated() -> bool { + false +} + impl AppScope { /// Get value pub fn value(&self) -> &String { diff --git a/src/models/app_scope_list.rs b/src/models/app_scope_list.rs index 0d93b62..cd03802 100644 --- a/src/models/app_scope_list.rs +++ b/src/models/app_scope_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppScopeList { /// Total number of scopes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppScopeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret.rs b/src/models/app_secret.rs index a32282b..43fd6cd 100644 --- a/src/models/app_secret.rs +++ b/src/models/app_secret.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecret { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Always empty. The application client secret is returned only once, in the /// response of the createSecret method. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecret { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_secret_list.rs b/src/models/app_secret_list.rs index f9df34d..23dcef0 100644 --- a/src/models/app_secret_list.rs +++ b/src/models/app_secret_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretList { /// Total number of secrets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppSecretList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret_plaintext.rs b/src/models/app_secret_plaintext.rs index 4c7a292..486d526 100644 --- a/src/models/app_secret_plaintext.rs +++ b/src/models/app_secret_plaintext.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretPlaintext { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Application client secret. Returned only when the secret is created; /// subsequent reads always return an empty value. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecretPlaintext { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecretPlaintext { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/apps_list.rs b/src/models/apps_list.rs index 6f31208..b8c106d 100644 --- a/src/models/apps_list.rs +++ b/src/models/apps_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppsList { /// Total number of apps that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of apps. #[serde(rename = "apps")] + #[serde(default = "default_apps")] pub apps: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_apps() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppsList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_bigint.rs b/src/models/attribute_bigint.rs index 7dffebc..9f298a7 100644 --- a/src/models/attribute_bigint.rs +++ b/src/models/attribute_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBigint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBigint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBigint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_boolean.rs b/src/models/attribute_boolean.rs index e6ddcc3..e08baa3 100644 --- a/src/models/attribute_boolean.rs +++ b/src/models/attribute_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBoolean { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBoolean { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_datetime.rs b/src/models/attribute_datetime.rs index beacd6d..79621c2 100644 --- a/src/models/attribute_datetime.rs +++ b/src/models/attribute_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeDatetime { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeDatetime { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct AttributeDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_email.rs b/src/models/attribute_email.rs index 2f172f7..76dcae3 100644 --- a/src/models/attribute_email.rs +++ b/src/models/attribute_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEmail { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEmail { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeEmail { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl AttributeEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_enum.rs b/src/models/attribute_enum.rs index f78d0eb..620db3a 100644 --- a/src/models/attribute_enum.rs +++ b/src/models/attribute_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEnum { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEnum { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct AttributeEnum { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -46,6 +54,38 @@ pub struct AttributeEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl AttributeEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_float.rs b/src/models/attribute_float.rs index 49cda73..a8467e7 100644 --- a/src/models/attribute_float.rs +++ b/src/models/attribute_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeFloat { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeFloat { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeFloat { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_integer.rs b/src/models/attribute_integer.rs index 39cad56..abb02d0 100644 --- a/src/models/attribute_integer.rs +++ b/src/models/attribute_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeInteger { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeInteger { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeInteger { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_ip.rs b/src/models/attribute_ip.rs index 2328c38..85c4070 100644 --- a/src/models/attribute_ip.rs +++ b/src/models/attribute_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeIp { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeIp { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeIp { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl AttributeIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_line.rs b/src/models/attribute_line.rs index 975994b..670484f 100644 --- a/src/models/attribute_line.rs +++ b/src/models/attribute_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLine { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLine { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLine { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_list.rs b/src/models/attribute_list.rs index d405e6d..73e9346 100644 --- a/src/models/attribute_list.rs +++ b/src/models/attribute_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AttributeList { /// Total number of attributes in the given collection. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AttributeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_longtext.rs b/src/models/attribute_longtext.rs index b613bf1..a45a044 100644 --- a/src/models/attribute_longtext.rs +++ b/src/models/attribute_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLongtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLongtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_mediumtext.rs b/src/models/attribute_mediumtext.rs index 98fcecd..18271f2 100644 --- a/src/models/attribute_mediumtext.rs +++ b/src/models/attribute_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeMediumtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeMediumtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_object.rs b/src/models/attribute_object.rs index 02515bf..ce3af14 100644 --- a/src/models/attribute_object.rs +++ b/src/models/attribute_object.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeObject { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeObject { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,38 @@ pub struct AttributeObject { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeObject { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_point.rs b/src/models/attribute_point.rs index 9ca02a2..d9284e1 100644 --- a/src/models/attribute_point.rs +++ b/src/models/attribute_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePoint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePoint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePoint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_polygon.rs b/src/models/attribute_polygon.rs index 3d39979..59a058b 100644 --- a/src/models/attribute_polygon.rs +++ b/src/models/attribute_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePolygon { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePolygon { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePolygon { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_relationship.rs b/src/models/attribute_relationship.rs index ce0efaf..17b1786 100644 --- a/src/models/attribute_relationship.rs +++ b/src/models/attribute_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeRelationship { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct AttributeRelationship { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related collection. #[serde(rename = "relatedCollection")] pub related_collection: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl AttributeRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_string.rs b/src/models/attribute_string.rs index 93dc8bc..eacad88 100644 --- a/src/models/attribute_string.rs +++ b/src/models/attribute_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeString { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeString { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeString { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_text.rs b/src/models/attribute_text.rs index 838d477..bf666ea 100644 --- a/src/models/attribute_text.rs +++ b/src/models/attribute_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeText { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeText { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeText { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_url.rs b/src/models/attribute_url.rs index 4dfc86c..2305191 100644 --- a/src/models/attribute_url.rs +++ b/src/models/attribute_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeUrl { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeUrl { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeUrl { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl AttributeUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_varchar.rs b/src/models/attribute_varchar.rs index 433fc29..a3277a9 100644 --- a/src/models/attribute_varchar.rs +++ b/src/models/attribute_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVarchar { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeVarchar { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_vector.rs b/src/models/attribute_vector.rs index 2472da9..79dc1c8 100644 --- a/src/models/attribute_vector.rs +++ b/src/models/attribute_vector.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVector { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVector { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,46 @@ pub struct AttributeVector { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Vector dimensions. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVector { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/backup_archive.rs b/src/models/backup_archive.rs index f4811a5..d64dce1 100644 --- a/src/models/backup_archive.rs +++ b/src/models/backup_archive.rs @@ -8,34 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchive { /// Archive ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Archive creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Archive update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Archive policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, - /// Archive size in bytes. + /// Archive size in bytes. Null until the size is known. #[serde(rename = "size")] - pub size: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, /// The status of the archive creation. Possible values: pending, processing, /// uploading, completed, failed, skipped. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The backup start time. Null until the backup starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this archive. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this archive. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this archive should backup a single /// resource. @@ -49,6 +59,38 @@ pub struct BackupArchive { pub resource_type: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchive { /// Get id pub fn id(&self) -> &String { @@ -70,9 +112,15 @@ impl BackupArchive { &self.policy_id } + /// Set size + pub fn set_size(mut self, size: i64) -> Self { + self.size = Some(size); + self + } + /// Get size - pub fn size(&self) -> &i64 { - &self.size + pub fn size(&self) -> Option<&i64> { + self.size.as_ref() } /// Get status @@ -80,9 +128,15 @@ impl BackupArchive { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -134,9 +188,7 @@ mod tests { let _ = _model.created_at(); let _ = _model.updated_at(); let _ = _model.policy_id(); - let _ = _model.size(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_archive_list.rs b/src/models/backup_archive_list.rs index 46af024..6c12aea 100644 --- a/src/models/backup_archive_list.rs +++ b/src/models/backup_archive_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchiveList { /// Total number of archives that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of archives. #[serde(rename = "archives")] + #[serde(default = "default_archives")] pub archives: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_archives() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchiveList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_policy.rs b/src/models/backup_policy.rs index 0ee8535..5c2c5a7 100644 --- a/src/models/backup_policy.rs +++ b/src/models/backup_policy.rs @@ -8,21 +8,27 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicy { /// Backup policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup policy name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Policy creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Policy update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this policy should backup a single /// resource. @@ -36,19 +42,63 @@ pub struct BackupPolicy { pub resource_type: Option, /// How many days to keep the backup before it will be automatically deleted. #[serde(rename = "retention")] + #[serde(default = "default_retention")] pub retention: i64, /// Policy backup schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Is this policy enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_retention() -> i64 { + 1 +} + +fn default_schedule() -> String { + "0 * * * *".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_enabled() -> bool { + false +} + impl BackupPolicy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/backup_policy_list.rs b/src/models/backup_policy_list.rs index 299f36b..60a4ad3 100644 --- a/src/models/backup_policy_list.rs +++ b/src/models/backup_policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicyList { /// Total number of policies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupPolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_restoration.rs b/src/models/backup_restoration.rs index 45931ed..2dc302b 100644 --- a/src/models/backup_restoration.rs +++ b/src/models/backup_restoration.rs @@ -8,38 +8,89 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Restoration update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Backup archive ID. #[serde(rename = "archiveId")] + #[serde(default = "default_archive_id")] pub archive_id: String, /// Backup policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// The status of the restoration. Possible values: pending, downloading, /// processing, completed, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The restoration start time. Null until the restoration starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, - /// Optional data in key-value object. + /// Restoration options as a key-value object. #[serde(rename = "options")] - pub options: String, + #[serde(default = "default_options")] + pub options: serde_json::Value, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_archive_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_options() -> serde_json::Value { + serde_json::json!({}) } impl BackupRestoration { @@ -73,9 +124,15 @@ impl BackupRestoration { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -94,7 +151,7 @@ impl BackupRestoration { } /// Get options - pub fn options(&self) -> &String { + pub fn options(&self) -> &serde_json::Value { &self.options } } @@ -112,7 +169,6 @@ mod tests { let _ = _model.archive_id(); let _ = _model.policy_id(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_restoration_list.rs b/src/models/backup_restoration_list.rs index 65c9ad3..33d4196 100644 --- a/src/models/backup_restoration_list.rs +++ b/src/models/backup_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/billing_plan.rs b/src/models/billing_plan.rs index 936f3d8..1e43f95 100644 --- a/src/models/billing_plan.rs +++ b/src/models/billing_plan.rs @@ -8,33 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlan { /// Plan ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Plan name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Plan description #[serde(rename = "desc")] + #[serde(default = "default_desc")] pub desc: String, /// Plan order #[serde(rename = "order")] + #[serde(default = "default_order")] pub order: i64, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Trial days #[serde(rename = "trial")] + #[serde(default = "default_trial")] pub trial: i64, /// Bandwidth #[serde(rename = "bandwidth")] + #[serde(default = "default_bandwidth")] pub bandwidth: i64, /// Storage #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Image Transformations #[serde(rename = "imageTransformations")] + #[serde(default = "default_image_transformations")] pub image_transformations: i64, /// Screenshots generated #[serde(rename = "screenshotsGenerated")] + #[serde(default = "default_screenshots_generated")] pub screenshots_generated: i64, /// Members #[serde(rename = "members")] @@ -42,77 +52,100 @@ pub struct BillingPlan { pub members: Option, /// Webhooks #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: i64, /// Maximum WAF rules per project #[serde(rename = "wafRules")] + #[serde(default = "default_waf_rules")] pub waf_rules: i64, /// Maximum environments per project. 0 when the plan does not offer /// environments. #[serde(rename = "environments")] - #[serde(skip_serializing_if = "Option::is_none")] - pub environments: Option, + #[serde(default = "default_environments")] + pub environments: i64, /// Projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: i64, /// Platforms #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: i64, /// Users #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: i64, /// Teams #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: i64, /// Databases #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: i64, /// Database reads per month #[serde(rename = "databasesReads")] + #[serde(default = "default_databases_reads")] pub databases_reads: i64, /// Database writes per month #[serde(rename = "databasesWrites")] + #[serde(default = "default_databases_writes")] pub databases_writes: i64, /// Database batch size limit #[serde(rename = "databasesBatchSize")] + #[serde(default = "default_databases_batch_size")] pub databases_batch_size: i64, /// Buckets #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: i64, /// File size #[serde(rename = "fileSize")] + #[serde(default = "default_file_size")] pub file_size: i64, /// Functions #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: i64, /// Sites #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: i64, /// Function executions #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: i64, /// Rolling max executions retained per function/site #[serde(rename = "executionsRetentionCount")] + #[serde(default = "default_executions_retention_count")] pub executions_retention_count: i64, /// GB hours for functions #[serde(rename = "GBHours")] + #[serde(default = "default_gb_hours")] pub gb_hours: i64, /// Realtime connections #[serde(rename = "realtime")] + #[serde(default = "default_realtime")] pub realtime: i64, /// Realtime messages #[serde(rename = "realtimeMessages")] + #[serde(default = "default_realtime_messages")] pub realtime_messages: i64, /// Messages per month #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: i64, /// Topics for messaging #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: i64, /// SMS authentications per month #[serde(rename = "authPhone")] + #[serde(default = "default_auth_phone")] pub auth_phone: i64, /// Custom domains #[serde(rename = "domains")] + #[serde(default = "default_domains")] pub domains: i64, /// Activity log days #[serde(rename = "activityLogs")] @@ -120,6 +153,7 @@ pub struct BillingPlan { pub activity_logs: Option, /// Usage history days #[serde(rename = "usageLogs")] + #[serde(default = "default_usage_logs")] pub usage_logs: i64, /// Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). #[serde(rename = "usageLogsIntervals")] @@ -134,30 +168,38 @@ pub struct BillingPlan { /// Number of days of console inactivity before a project is paused. 0 means /// pausing is disabled. #[serde(rename = "projectInactivityDays")] + #[serde(default = "default_project_inactivity_days")] pub project_inactivity_days: i64, /// Alert threshold percentage #[serde(rename = "alertLimit")] + #[serde(default = "default_alert_limit")] pub alert_limit: i64, - /// Additional resources + /// Additional resources. Null when the plan does not support usage billing. #[serde(rename = "usage")] - pub usage: crate::models::UsageBillingPlan, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage: Option, /// Addons #[serde(rename = "addons")] pub addons: crate::models::BillingPlanAddon, /// Budget cap enabled or disabled. #[serde(rename = "budgetCapEnabled")] + #[serde(default = "default_budget_cap_enabled")] pub budget_cap_enabled: bool, /// Custom SMTP #[serde(rename = "customSmtp")] + #[serde(default = "default_custom_smtp")] pub custom_smtp: bool, /// Appwrite branding in email #[serde(rename = "emailBranding")] + #[serde(default = "default_email_branding")] pub email_branding: bool, /// Does plan require payment method #[serde(rename = "requiresPaymentMethod")] + #[serde(default = "default_requires_payment_method")] pub requires_payment_method: bool, /// Does plan require billing address #[serde(rename = "requiresBillingAddress")] + #[serde(default = "default_requires_billing_address")] pub requires_billing_address: bool, /// ISO country codes eligible for this regional plan. Empty means no /// restriction. @@ -166,42 +208,55 @@ pub struct BillingPlan { pub eligible_countries: Option>, /// Is the billing plan available #[serde(rename = "isAvailable")] + #[serde(default = "default_is_available")] pub is_available: bool, /// Can user change the plan themselves #[serde(rename = "selfService")] + #[serde(default = "default_self_service")] pub self_service: bool, /// Does plan enable premium support #[serde(rename = "premiumSupport")] + #[serde(default = "default_premium_support")] pub premium_support: bool, /// Does plan support budget cap #[serde(rename = "budgeting")] + #[serde(default = "default_budgeting")] pub budgeting: bool, /// Does plan support mock numbers #[serde(rename = "supportsMockNumbers")] + #[serde(default = "default_supports_mock_numbers")] pub supports_mock_numbers: bool, /// Does plan support organization roles #[serde(rename = "supportsOrganizationRoles")] + #[serde(default = "default_supports_organization_roles")] pub supports_organization_roles: bool, /// Does plan support credit #[serde(rename = "supportsCredits")] + #[serde(default = "default_supports_credits")] pub supports_credits: bool, /// Does plan support dedicated databases. #[serde(rename = "supportsDedicatedDatabases")] + #[serde(default = "default_supports_dedicated_databases")] pub supports_dedicated_databases: bool, /// Does plan support blocking disposable email addresses. #[serde(rename = "supportsDisposableEmailValidation")] + #[serde(default = "default_supports_disposable_email_validation")] pub supports_disposable_email_validation: bool, /// Does plan support requiring canonical email addresses. #[serde(rename = "supportsCanonicalEmailValidation")] + #[serde(default = "default_supports_canonical_email_validation")] pub supports_canonical_email_validation: bool, /// Does plan support blocking free email addresses. #[serde(rename = "supportsFreeEmailValidation")] + #[serde(default = "default_supports_free_email_validation")] pub supports_free_email_validation: bool, /// Does plan support restricting sign-ups to corporate email addresses only. #[serde(rename = "supportsCorporateEmailValidation")] + #[serde(default = "default_supports_corporate_email_validation")] pub supports_corporate_email_validation: bool, /// Does plan support project-specific member roles. #[serde(rename = "supportsProjectSpecificRoles")] + #[serde(default = "default_supports_project_specific_roles")] pub supports_project_specific_roles: bool, /// Does plan support backup policies. #[serde(rename = "backupsEnabled")] @@ -209,6 +264,7 @@ pub struct BillingPlan { pub backups_enabled: Option, /// Whether usage addons are calculated per project. #[serde(rename = "usagePerProject")] + #[serde(default = "default_usage_per_project")] pub usage_per_project: bool, /// Supported addons for this plan #[serde(rename = "supportedAddons")] @@ -219,16 +275,20 @@ pub struct BillingPlan { pub backup_policies: Option, /// Maximum function and site deployment size in MB #[serde(rename = "deploymentSize")] + #[serde(default = "default_deployment_size")] pub deployment_size: i64, /// Maximum function and site deployment size in MB #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// Shortest function schedule interval allowed, in minutes. 0 allows every /// interval. #[serde(rename = "functionsIntervalMinimum")] + #[serde(default = "default_functions_interval_minimum")] pub functions_interval_minimum: i64, /// Does the plan support encrypted string attributes or not. #[serde(rename = "databasesAllowEncrypt")] + #[serde(default = "default_databases_allow_encrypt")] pub databases_allow_encrypt: bool, /// Plan specific limits #[serde(rename = "limits")] @@ -244,6 +304,7 @@ pub struct BillingPlan { /// Included monthly dedicated-database compute credit in USD. Resets each /// billing cycle with no roll-over. #[serde(rename = "databaseComputeCredit")] + #[serde(default = "default_database_compute_credit")] pub database_compute_credit: f64, /// Dedicated database limits available to this plan. #[serde(rename = "dedicatedDatabases")] @@ -251,6 +312,250 @@ pub struct BillingPlan { pub dedicated_databases: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_desc() -> String { + "".to_string() +} + +fn default_order() -> i64 { + 0 +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_trial() -> i64 { + 0 +} + +fn default_bandwidth() -> i64 { + 0 +} + +fn default_storage() -> i64 { + 0 +} + +fn default_image_transformations() -> i64 { + 0 +} + +fn default_screenshots_generated() -> i64 { + 0 +} + +fn default_webhooks() -> i64 { + 0 +} + +fn default_waf_rules() -> i64 { + 0 +} + +fn default_environments() -> i64 { + 0 +} + +fn default_projects() -> i64 { + 0 +} + +fn default_platforms() -> i64 { + 0 +} + +fn default_users() -> i64 { + 0 +} + +fn default_teams() -> i64 { + 0 +} + +fn default_databases() -> i64 { + 0 +} + +fn default_databases_reads() -> i64 { + 0 +} + +fn default_databases_writes() -> i64 { + 0 +} + +fn default_databases_batch_size() -> i64 { + 0 +} + +fn default_buckets() -> i64 { + 0 +} + +fn default_file_size() -> i64 { + 0 +} + +fn default_functions() -> i64 { + 0 +} + +fn default_sites() -> i64 { + 0 +} + +fn default_executions() -> i64 { + 0 +} + +fn default_executions_retention_count() -> i64 { + 1000 +} + +fn default_gb_hours() -> i64 { + 0 +} + +fn default_realtime() -> i64 { + 0 +} + +fn default_realtime_messages() -> i64 { + 0 +} + +fn default_messages() -> i64 { + 0 +} + +fn default_topics() -> i64 { + 0 +} + +fn default_auth_phone() -> i64 { + 0 +} + +fn default_domains() -> i64 { + 0 +} + +fn default_usage_logs() -> i64 { + 0 +} + +fn default_project_inactivity_days() -> i64 { + 0 +} + +fn default_alert_limit() -> i64 { + 80 +} + +fn default_budget_cap_enabled() -> bool { + false +} + +fn default_custom_smtp() -> bool { + false +} + +fn default_email_branding() -> bool { + false +} + +fn default_requires_payment_method() -> bool { + true +} + +fn default_requires_billing_address() -> bool { + false +} + +fn default_is_available() -> bool { + true +} + +fn default_self_service() -> bool { + true +} + +fn default_premium_support() -> bool { + true +} + +fn default_budgeting() -> bool { + true +} + +fn default_supports_mock_numbers() -> bool { + true +} + +fn default_supports_organization_roles() -> bool { + true +} + +fn default_supports_credits() -> bool { + false +} + +fn default_supports_dedicated_databases() -> bool { + false +} + +fn default_supports_disposable_email_validation() -> bool { + false +} + +fn default_supports_canonical_email_validation() -> bool { + false +} + +fn default_supports_free_email_validation() -> bool { + false +} + +fn default_supports_corporate_email_validation() -> bool { + false +} + +fn default_supports_project_specific_roles() -> bool { + false +} + +fn default_usage_per_project() -> bool { + true +} + +fn default_deployment_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_functions_interval_minimum() -> i64 { + 0 +} + +fn default_databases_allow_encrypt() -> bool { + false +} + +fn default_database_compute_credit() -> f64 { + 0.0 +} + impl BillingPlan { /// Get id pub fn id(&self) -> &String { @@ -323,15 +628,9 @@ impl BillingPlan { &self.waf_rules } - /// Set environments - pub fn set_environments(mut self, environments: i64) -> Self { - self.environments = Some(environments); - self - } - /// Get environments - pub fn environments(&self) -> Option<&i64> { - self.environments.as_ref() + pub fn environments(&self) -> &i64 { + &self.environments } /// Get projects @@ -490,9 +789,15 @@ impl BillingPlan { &self.alert_limit } + /// Set usage + pub fn set_usage(mut self, usage: crate::models::UsageBillingPlan) -> Self { + self.usage = Some(usage); + self + } + /// Get usage - pub fn usage(&self) -> &crate::models::UsageBillingPlan { - &self.usage + pub fn usage(&self) -> Option<&crate::models::UsageBillingPlan> { + self.usage.as_ref() } /// Get addons @@ -721,6 +1026,7 @@ mod tests { let _ = _model.screenshots_generated(); let _ = _model.webhooks(); let _ = _model.waf_rules(); + let _ = _model.environments(); let _ = _model.projects(); let _ = _model.platforms(); let _ = _model.users(); @@ -745,7 +1051,6 @@ mod tests { let _ = _model.usage_logs(); let _ = _model.project_inactivity_days(); let _ = _model.alert_limit(); - let _ = _model.usage(); let _ = _model.addons(); let _ = _model.budget_cap_enabled(); let _ = _model.custom_smtp(); diff --git a/src/models/billing_plan_addon_details.rs b/src/models/billing_plan_addon_details.rs index 00aa018..3557b0d 100644 --- a/src/models/billing_plan_addon_details.rs +++ b/src/models/billing_plan_addon_details.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanAddonDetails { /// Is the addon supported in the plan? #[serde(rename = "supported")] + #[serde(default = "default_supported")] pub supported: bool, /// Addon plan included value #[serde(rename = "planIncluded")] + #[serde(default = "default_plan_included")] pub plan_included: i64, /// Addon limit #[serde(rename = "limit")] + #[serde(default = "default_limit")] pub limit: i64, /// Addon type #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Price currency #[serde(rename = "currency")] @@ -24,15 +28,46 @@ pub struct BillingPlanAddonDetails { pub currency: Option, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_supported() -> bool { + false +} + +fn default_plan_included() -> i64 { + 0 +} + +fn default_limit() -> i64 { + 0 +} + +fn default_type() -> String { + "numeric".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl BillingPlanAddonDetails { /// Get supported pub fn supported(&self) -> &bool { diff --git a/src/models/billing_plan_supported_addons.rs b/src/models/billing_plan_supported_addons.rs index af95b2d..74f7ee1 100644 --- a/src/models/billing_plan_supported_addons.rs +++ b/src/models/billing_plan_supported_addons.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanSupportedAddons { /// Whether the plan supports BAA (Business Associate Agreement) addon #[serde(rename = "baa")] + #[serde(default = "default_baa")] pub baa: bool, /// Whether the plan supports Premium Geo DB addon (project-level) #[serde(rename = "premiumGeoDB")] + #[serde(default = "default_premium_geo_db")] pub premium_geo_db: bool, /// Whether the plan supports Premium Geo DB addon (organization-level) #[serde(rename = "premiumGeoDBOrg")] + #[serde(default = "default_premium_geo_db_org")] pub premium_geo_db_org: bool, } +fn default_baa() -> bool { + false +} + +fn default_premium_geo_db() -> bool { + false +} + +fn default_premium_geo_db_org() -> bool { + false +} + impl BillingPlanSupportedAddons { /// Get baa pub fn baa(&self) -> &bool { diff --git a/src/models/block.rs b/src/models/block.rs index 9bd4591..8af751d 100644 --- a/src/models/block.rs +++ b/src/models/block.rs @@ -8,40 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct Block { /// Block creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource type that is blocked #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource identifier that is blocked #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Block mode. full blocks reads and writes; readOnly blocks writes only. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, - /// Reason for the block. Can be null if no reason was provided. - #[serde(rename = "reason")] - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// Block expiration date in ISO 8601 format. Can be null if the block does not /// expire. #[serde(rename = "expiredAt")] #[serde(skip_serializing_if = "Option::is_none")] pub expired_at: Option, - /// Name of the project this block applies to. - #[serde(rename = "projectName")] - pub project_name: String, - /// Region of the project this block applies to. - #[serde(rename = "region")] - pub region: String, - /// Name of the organization that owns the project. - #[serde(rename = "organizationName")] - pub organization_name: String, - /// ID of the organization that owns the project. - #[serde(rename = "organizationId")] - pub organization_id: String, - /// Billing plan of the organization that owns the project. - #[serde(rename = "billingPlan")] - pub billing_plan: String, +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_mode() -> String { + "full".to_string() } impl Block { @@ -65,17 +66,6 @@ impl Block { &self.mode } - /// Set reason - pub fn set_reason(mut self, reason: String) -> Self { - self.reason = Some(reason); - self - } - - /// Get reason - pub fn reason(&self) -> Option<&String> { - self.reason.as_ref() - } - /// Set expired_at pub fn set_expired_at(mut self, expired_at: String) -> Self { self.expired_at = Some(expired_at); @@ -86,31 +76,6 @@ impl Block { pub fn expired_at(&self) -> Option<&String> { self.expired_at.as_ref() } - - /// Get project_name - pub fn project_name(&self) -> &String { - &self.project_name - } - - /// Get region - pub fn region(&self) -> &String { - &self.region - } - - /// Get organization_name - pub fn organization_name(&self) -> &String { - &self.organization_name - } - - /// Get organization_id - pub fn organization_id(&self) -> &String { - &self.organization_id - } - - /// Get billing_plan - pub fn billing_plan(&self) -> &String { - &self.billing_plan - } } #[cfg(test)] @@ -124,11 +89,6 @@ mod tests { let _ = _model.resource_type(); let _ = _model.resource_id(); let _ = _model.mode(); - let _ = _model.project_name(); - let _ = _model.region(); - let _ = _model.organization_name(); - let _ = _model.organization_id(); - let _ = _model.billing_plan(); } #[test] diff --git a/src/models/bucket.rs b/src/models/bucket.rs index 8140e6a..feffbb9 100644 --- a/src/models/bucket.rs +++ b/src/models/bucket.rs @@ -8,52 +8,122 @@ use serde::{Deserialize, Serialize}; pub struct Bucket { /// Bucket ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Bucket update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Bucket permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Whether file-level security is enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "fileSecurity")] + #[serde(default = "default_file_security")] pub file_security: bool, /// Bucket name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Bucket enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Maximum file size supported. #[serde(rename = "maximumFileSize")] + #[serde(default = "default_maximum_file_size")] pub maximum_file_size: i64, /// Allowed file extensions. #[serde(rename = "allowedFileExtensions")] + #[serde(default = "default_allowed_file_extensions")] pub allowed_file_extensions: Vec, /// Compression algorithm chosen for compression. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, /// Bucket is encrypted. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Virus scanning is enabled. #[serde(rename = "antivirus")] + #[serde(default = "default_antivirus")] pub antivirus: bool, /// Image transformations are enabled. #[serde(rename = "transformations")] + #[serde(default = "default_transformations")] pub transformations: bool, /// Total size of this bucket in bytes. #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_file_security() -> bool { + false +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_maximum_file_size() -> i64 { + 0 +} + +fn default_allowed_file_extensions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_compression() -> String { + "".to_string() +} + +fn default_encryption() -> bool { + true +} + +fn default_antivirus() -> bool { + true +} + +fn default_transformations() -> bool { + true +} + +fn default_total_size() -> i64 { + 0 +} + impl Bucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/bucket_list.rs b/src/models/bucket_list.rs index 0f76efc..a29bb00 100644 --- a/src/models/bucket_list.rs +++ b/src/models/bucket_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BucketList { /// Total number of buckets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of buckets. #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_buckets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BucketList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/collection.rs b/src/models/collection.rs index 715c303..fd9bc8a 100644 --- a/src/models/collection.rs +++ b/src/models/collection.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Collection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Collection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/collection_list.rs b/src/models/collection_list.rs index 97983c6..c9f7bfe 100644 --- a/src/models/collection_list.rs +++ b/src/models/collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_bigint.rs b/src/models/column_bigint.rs index 1228086..9dd23d7 100644 --- a/src/models/column_bigint.rs +++ b/src/models/column_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBigint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBigint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBigint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_boolean.rs b/src/models/column_boolean.rs index 65aa9af..d2f4fe9 100644 --- a/src/models/column_boolean.rs +++ b/src/models/column_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBoolean { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBoolean { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_datetime.rs b/src/models/column_datetime.rs index a172665..13c23ca 100644 --- a/src/models/column_datetime.rs +++ b/src/models/column_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnDatetime { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnDatetime { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct ColumnDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_email.rs b/src/models/column_email.rs index f1c1037..5fc9bb6 100644 --- a/src/models/column_email.rs +++ b/src/models/column_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEmail { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEmail { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnEmail { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl ColumnEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_enum.rs b/src/models/column_enum.rs index d9b6b4f..bf66e79 100644 --- a/src/models/column_enum.rs +++ b/src/models/column_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEnum { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEnum { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct ColumnEnum { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -46,6 +54,38 @@ pub struct ColumnEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl ColumnEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_float.rs b/src/models/column_float.rs index 865bd38..55326bc 100644 --- a/src/models/column_float.rs +++ b/src/models/column_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnFloat { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnFloat { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnFloat { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_index.rs b/src/models/column_index.rs index 7e2a97b..ec406a7 100644 --- a/src/models/column_index.rs +++ b/src/models/column_index.rs @@ -8,32 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndex { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Index columns length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +50,42 @@ pub struct ColumnIndex { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/column_index_list.rs b/src/models/column_index_list.rs index 2ea7645..748a2c5 100644 --- a/src/models/column_index_list.rs +++ b/src/models/column_index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_integer.rs b/src/models/column_integer.rs index 8a6cd9e..39fb5f6 100644 --- a/src/models/column_integer.rs +++ b/src/models/column_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnInteger { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnInteger { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnInteger { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_ip.rs b/src/models/column_ip.rs index a94cf00..9aa5287 100644 --- a/src/models/column_ip.rs +++ b/src/models/column_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIp { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnIp { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnIp { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl ColumnIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_line.rs b/src/models/column_line.rs index 01d2239..6befae7 100644 --- a/src/models/column_line.rs +++ b/src/models/column_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLine { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLine { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLine { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_list.rs b/src/models/column_list.rs index aaa362b..55fc758 100644 --- a/src/models/column_list.rs +++ b/src/models/column_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnList { /// Total number of columns in the given table. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_longtext.rs b/src/models/column_longtext.rs index 6d418d9..222e746 100644 --- a/src/models/column_longtext.rs +++ b/src/models/column_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLongtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLongtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_mediumtext.rs b/src/models/column_mediumtext.rs index 90b3d33..f1c032b 100644 --- a/src/models/column_mediumtext.rs +++ b/src/models/column_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnMediumtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnMediumtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_point.rs b/src/models/column_point.rs index 6d402ea..4b08010 100644 --- a/src/models/column_point.rs +++ b/src/models/column_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPoint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPoint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPoint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_polygon.rs b/src/models/column_polygon.rs index d0afe7e..5ff50f0 100644 --- a/src/models/column_polygon.rs +++ b/src/models/column_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPolygon { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPolygon { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPolygon { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_relationship.rs b/src/models/column_relationship.rs index 441476a..92304e7 100644 --- a/src/models/column_relationship.rs +++ b/src/models/column_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnRelationship { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct ColumnRelationship { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related table. #[serde(rename = "relatedTable")] pub related_table: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl ColumnRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_string.rs b/src/models/column_string.rs index c7128c3..8d8e515 100644 --- a/src/models/column_string.rs +++ b/src/models/column_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnString { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnString { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnString { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_text.rs b/src/models/column_text.rs index 0ad76c5..e1b305c 100644 --- a/src/models/column_text.rs +++ b/src/models/column_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnText { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnText { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnText { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_url.rs b/src/models/column_url.rs index b509d2f..4fce4a3 100644 --- a/src/models/column_url.rs +++ b/src/models/column_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnUrl { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnUrl { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnUrl { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl ColumnUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_varchar.rs b/src/models/column_varchar.rs index e163c87..53e8c58 100644 --- a/src/models/column_varchar.rs +++ b/src/models/column_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnVarchar { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnVarchar { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/continent.rs b/src/models/continent.rs index c13199c..34286cd 100644 --- a/src/models/continent.rs +++ b/src/models/continent.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Continent { /// Continent name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Continent two letter code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Continent { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/continent_list.rs b/src/models/continent_list.rs index 2490dbd..677e579 100644 --- a/src/models/continent_list.rs +++ b/src/models/continent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ContinentList { /// Total number of continents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of continents. #[serde(rename = "continents")] + #[serde(default = "default_continents")] pub continents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_continents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ContinentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/country.rs b/src/models/country.rs index bf48f60..2c9db22 100644 --- a/src/models/country.rs +++ b/src/models/country.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Country { /// Country name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Country { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/country_list.rs b/src/models/country_list.rs index bf4eeb1..b004cb8 100644 --- a/src/models/country_list.rs +++ b/src/models/country_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CountryList { /// Total number of countries that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of countries. #[serde(rename = "countries")] + #[serde(default = "default_countries")] pub countries: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_countries() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CountryList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/currency.rs b/src/models/currency.rs index 9d45fe6..c5d5091 100644 --- a/src/models/currency.rs +++ b/src/models/currency.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct Currency { /// Currency symbol. #[serde(rename = "symbol")] + #[serde(default = "default_symbol")] pub symbol: String, /// Currency name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Currency native symbol. #[serde(rename = "symbolNative")] + #[serde(default = "default_symbol_native")] pub symbol_native: String, /// Number of decimal digits. #[serde(rename = "decimalDigits")] + #[serde(default = "default_decimal_digits")] pub decimal_digits: i64, /// Currency digit rounding. #[serde(rename = "rounding")] + #[serde(default = "default_rounding")] pub rounding: f64, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Currency plural name #[serde(rename = "namePlural")] + #[serde(default = "default_name_plural")] pub name_plural: String, } +fn default_symbol() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_symbol_native() -> String { + "".to_string() +} + +fn default_decimal_digits() -> i64 { + 0 +} + +fn default_rounding() -> f64 { + 0.0 +} + +fn default_code() -> String { + "".to_string() +} + +fn default_name_plural() -> String { + "".to_string() +} + impl Currency { /// Get symbol pub fn symbol(&self) -> &String { diff --git a/src/models/currency_list.rs b/src/models/currency_list.rs index 86fa828..001a779 100644 --- a/src/models/currency_list.rs +++ b/src/models/currency_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CurrencyList { /// Total number of currencies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of currencies. #[serde(rename = "currencies")] + #[serde(default = "default_currencies")] pub currencies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_currencies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CurrencyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database.rs b/src/models/database.rs index 5c0a45d..b582d01 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -8,23 +8,29 @@ use serde::{Deserialize, Serialize}; pub struct Database { /// Database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Database creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the /// database is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Database type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: crate::enums::DatabaseType, /// Dedicated database lifecycle status. Null when the database has no valid /// dedicated backing. @@ -53,8 +59,9 @@ pub struct Database { #[serde(rename = "error")] #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, - /// Container status of the dedicated backing: active or inactive. Null when - /// the database has no dedicated backing or the runtime has not reported one. + /// Container status of the dedicated backing: active, inactive, or failed (a + /// wake was declined because the backing namespace is gone). Null when the + /// database has no dedicated backing or the runtime has not reported one. #[serde(rename = "containerStatus")] #[serde(skip_serializing_if = "Option::is_none")] pub container_status: Option, @@ -74,6 +81,30 @@ pub struct Database { pub archives: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> crate::enums::DatabaseType { + serde_json::from_value(serde_json::json!("legacy")).unwrap() +} + impl Database { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_list.rs b/src/models/database_list.rs index 78fe039..919f60b 100644 --- a/src/models/database_list.rs +++ b/src/models/database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_migration.rs b/src/models/database_migration.rs index 0a05aa6..e2ca204 100644 --- a/src/models/database_migration.rs +++ b/src/models/database_migration.rs @@ -8,63 +8,148 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigration { /// Database migration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Migration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Migration update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns the migrating database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Logical database ID being migrated. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Dedicated compute specification provisioned for the migration target. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Migration phase. Possible values: pending, provisioned, capturing, /// backfilling, catching_up, verifying, ready_to_cutover, cutover, soaking, /// done, failed, rolled_back. #[serde(rename = "phase")] + #[serde(default = "default_phase")] pub phase: String, /// Number of times a migration step has failed and been recorded. #[serde(rename = "attempt")] + #[serde(default = "default_attempt")] pub attempt: i64, /// Reason the most recent migration step failed, empty while none has. #[serde(rename = "lastError")] + #[serde(default = "default_last_error")] pub last_error: String, /// Number of documents still pending replication to the target. #[serde(rename = "lagDocuments")] + #[serde(default = "default_lag_documents")] pub lag_documents: i64, /// Highest source changelog sequence applied to the target so far. #[serde(rename = "changelogWatermark")] + #[serde(default = "default_changelog_watermark")] pub changelog_watermark: i64, /// Time the migrated data was verified against the source in ISO 8601 format. #[serde(rename = "verifiedAt")] + #[serde(default = "default_verified_at")] pub verified_at: String, /// Time routing was flipped to the target in ISO 8601 format. #[serde(rename = "cutoverAt")] + #[serde(default = "default_cutover_at")] pub cutover_at: String, /// Time the post-cutover soak window ends in ISO 8601 format. #[serde(rename = "soakUntil")] + #[serde(default = "default_soak_until")] pub soak_until: String, /// Whether the migration cuts over automatically once ready. Set when the /// migration is created and never changed afterwards, so it always reports /// what was asked for. #[serde(rename = "autoCutover")] + #[serde(default = "default_auto_cutover")] pub auto_cutover: bool, /// Whether a cutover has been requested and not yet attempted. Set by the /// cutover endpoint and cleared when the attempt is made, so a cutover that /// fails a check parks the migration again rather than retrying on its own. #[serde(rename = "cutoverRequested")] + #[serde(default = "default_cutover_requested")] pub cutover_requested: bool, /// Whether the migration is paused. #[serde(rename = "paused")] + #[serde(default = "default_paused")] pub paused: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_phase() -> String { + "pending".to_string() +} + +fn default_attempt() -> i64 { + 0 +} + +fn default_last_error() -> String { + "".to_string() +} + +fn default_lag_documents() -> i64 { + 0 +} + +fn default_changelog_watermark() -> i64 { + 0 +} + +fn default_verified_at() -> String { + "".to_string() +} + +fn default_cutover_at() -> String { + "".to_string() +} + +fn default_soak_until() -> String { + "".to_string() +} + +fn default_auto_cutover() -> bool { + true +} + +fn default_cutover_requested() -> bool { + false +} + +fn default_paused() -> bool { + false +} + impl DatabaseMigration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_migration_list.rs b/src/models/database_migration_list.rs index ad8e45f..1029847 100644 --- a/src/models/database_migration_list.rs +++ b/src/models/database_migration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigrationList { /// Total number of migrations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of migrations. #[serde(rename = "migrations")] + #[serde(default = "default_migrations")] pub migrations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_migrations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseMigrationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_status.rs b/src/models/database_status.rs index d0b0403..0796051 100644 --- a/src/models/database_status.rs +++ b/src/models/database_status.rs @@ -9,25 +9,32 @@ pub struct DatabaseStatus { /// Overall health status: healthy, degraded, unhealthy, or unknown when /// nothing could be measured. #[serde(rename = "health")] + #[serde(default = "default_health")] pub health: String, /// Whether the database is ready to accept connections. #[serde(rename = "ready")] + #[serde(default = "default_ready")] pub ready: bool, /// Database engine: postgresql, mysql, or mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Database uptime in seconds. #[serde(rename = "uptime")] + #[serde(default = "default_uptime")] pub uptime: i64, - /// Connection statistics. + /// Connection statistics. Null when the database has not been probed. #[serde(rename = "connections")] - pub connections: crate::models::DatabaseStatusConnections, + #[serde(skip_serializing_if = "Option::is_none")] + pub connections: Option, /// Requested replication sync mode. Possible values: async, sync, quorum. /// Compare with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. @@ -36,13 +43,16 @@ pub struct DatabaseStatus { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -62,12 +72,58 @@ pub struct DatabaseStatus { /// appears, including one the backend has not brought up, which is reported as /// not healthy. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: Vec, /// Storage volume information. #[serde(rename = "volumes")] + #[serde(default = "default_volumes")] pub volumes: Vec, } +fn default_health() -> String { + "unknown".to_string() +} + +fn default_ready() -> bool { + false +} + +fn default_engine() -> String { + "postgresql".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_uptime() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_replicas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_volumes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseStatus { /// Get health pub fn health(&self) -> &String { @@ -94,9 +150,18 @@ impl DatabaseStatus { &self.uptime } + /// Set connections + pub fn set_connections( + mut self, + connections: crate::models::DatabaseStatusConnections, + ) -> Self { + self.connections = Some(connections); + self + } + /// Get connections - pub fn connections(&self) -> &crate::models::DatabaseStatusConnections { - &self.connections + pub fn connections(&self) -> Option<&crate::models::DatabaseStatusConnections> { + self.connections.as_ref() } /// Get sync_mode @@ -164,7 +229,6 @@ mod tests { let _ = _model.engine(); let _ = _model.version(); let _ = _model.uptime(); - let _ = _model.connections(); let _ = _model.sync_mode(); let _ = _model.sync_degraded(); let _ = _model.sync_acknowledgements(); diff --git a/src/models/database_status_connections.rs b/src/models/database_status_connections.rs index 0e7652d..8d7110a 100644 --- a/src/models/database_status_connections.rs +++ b/src/models/database_status_connections.rs @@ -8,14 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusConnections { /// Current number of active connections. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: i64, /// The engine's own max_connections. On a pooled database this is the backend /// limit the pooler multiplexes onto, not the ceiling a client pool may reach /// — that is networkMaxConnections on the database resource. #[serde(rename = "max")] + #[serde(default = "default_max")] pub max: i64, } +fn default_current() -> i64 { + 0 +} + +fn default_max() -> i64 { + 100 +} + impl DatabaseStatusConnections { /// Get current pub fn current(&self) -> &i64 { diff --git a/src/models/database_status_replica.rs b/src/models/database_status_replica.rs index f182cdb..ad15e30 100644 --- a/src/models/database_status_replica.rs +++ b/src/models/database_status_replica.rs @@ -9,15 +9,18 @@ pub struct DatabaseStatusReplica { /// Member index within the database. Read `role` for which member accepts /// writes: a failover moves the primary without renumbering the indexes. #[serde(rename = "index")] + #[serde(default = "default_index")] pub index: i64, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology, so no member can be named /// the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Whether the replica is healthy. #[serde(rename = "healthy")] + #[serde(default = "default_healthy")] pub healthy: bool, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -35,6 +38,18 @@ pub struct DatabaseStatusReplica { pub lag_seconds: Option, } +fn default_index() -> i64 { + 0 +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_healthy() -> bool { + false +} + impl DatabaseStatusReplica { /// Get index pub fn index(&self) -> &i64 { diff --git a/src/models/database_status_volume.rs b/src/models/database_status_volume.rs index 35ea096..0d21f7a 100644 --- a/src/models/database_status_volume.rs +++ b/src/models/database_status_volume.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusVolume { /// Mount path of the volume. #[serde(rename = "path")] + #[serde(default = "default_path")] pub path: String, /// Percentage of storage used. #[serde(rename = "usedPercent")] + #[serde(default = "default_used_percent")] pub used_percent: String, /// Available storage space. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: String, /// Whether the volume is mounted. #[serde(rename = "mounted")] + #[serde(default = "default_mounted")] pub mounted: bool, } +fn default_path() -> String { + "".to_string() +} + +fn default_used_percent() -> String { + "0%".to_string() +} + +fn default_available() -> String { + "0GB".to_string() +} + +fn default_mounted() -> bool { + false +} + impl DatabaseStatusVolume { /// Get path pub fn path(&self) -> &String { diff --git a/src/models/dedicated_database.rs b/src/models/dedicated_database.rs index 33e9d5c..07cf2c4 100644 --- a/src/models/dedicated_database.rs +++ b/src/models/dedicated_database.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabase { /// Dedicated database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns this database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Database display name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Product API that owns this database: tablesdb, documentsdb, vectorsdb, /// mysql, postgresql, or mongodb. #[serde(rename = "api")] - pub api: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub api: Option, /// Database engine: postgresql, mysql, or mongodb. Null until the backing /// reports one. #[serde(rename = "engine")] - pub engine: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub engine: Option, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Specification identifier. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Database backend provider. Possible values: edge. #[serde(rename = "backend")] + #[serde(default = "default_backend")] pub backend: String, /// Database hostname for connections. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Database port for connections. Derived from the engine when the backing has /// not reported one yet. #[serde(rename = "connectionPort")] - pub connection_port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub connection_port: Option, /// Database username for connections. #[serde(rename = "connectionUser")] + #[serde(default = "default_connection_user")] pub connection_user: String, /// Database password for connections. #[serde(rename = "connectionPassword")] + #[serde(default = "default_connection_password")] pub connection_password: String, /// Committed generation of the primary connection credentials. Null until the /// rotation contract has been initialized. #[serde(rename = "credentialGeneration")] - pub credential_generation: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub credential_generation: Option, /// Full database connection string (URI format). #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, /// Whether SSL/TLS is required for client connections. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database status. Possible values: provisioning, ready, inactive, paused, /// failed, deleted, restoring, scaling. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// Container status for lifecycle-managed database runtimes: active or - /// inactive. + /// Container status for lifecycle-managed database runtimes: active, inactive, + /// or failed (a wake was declined because the backing namespace is gone). #[serde(rename = "containerStatus")] + #[serde(default = "default_container_status")] pub container_status: String, /// Last activity timestamp in ISO 8601 format. #[serde(rename = "lastAccessedAt")] @@ -82,29 +101,34 @@ pub struct DedicatedDatabase { /// Idle-lifecycle state of the database. Possible values: active, warm, cold, /// hibernated. #[serde(rename = "lifecycleState")] + #[serde(default = "default_lifecycle_state")] pub lifecycle_state: String, /// Minutes of inactivity before container scales to zero. #[serde(rename = "idleTimeoutMinutes")] + #[serde(default = "default_idle_timeout_minutes")] pub idle_timeout_minutes: i64, /// CPU allocated in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Memory allocated in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Storage allocated in GB. #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Storage resize status. Possible values: idle (no resize in flight), /// resizing (the volume is growing towards storageTargetGb). #[serde(rename = "storageStatus")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_status: Option, + #[serde(default = "default_storage_status")] + pub storage_status: String, /// Size in GB the volume is growing towards while storageStatus is resizing. 0 /// when no resize is in flight. #[serde(rename = "storageTargetGb")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_target_gb: Option, + #[serde(default = "default_storage_target_gb")] + pub storage_target_gb: i64, /// Time the in-flight storage resize started, in ISO 8601 format. #[serde(rename = "storageResizeStartedAt")] #[serde(skip_serializing_if = "Option::is_none")] @@ -112,86 +136,290 @@ pub struct DedicatedDatabase { /// Storage class. Currently always 'ssd'; DigitalOcean exposes a single /// block-storage class. #[serde(rename = "storageClass")] + #[serde(default = "default_storage_class")] pub storage_class: String, /// Maximum storage allowed in GB. 0 means use system default. #[serde(rename = "storageMaxGb")] + #[serde(default = "default_storage_max_gb")] pub storage_max_gb: i64, /// Kubernetes node pool where the database is scheduled. #[serde(rename = "nodePool")] + #[serde(default = "default_node_pool")] pub node_pool: String, /// Number of high availability replicas. High availability is enabled when /// greater than 0. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Replication sync mode: async, sync, or quorum. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Maximum concurrent client connections. This is the limit a client pool may /// reach; the engine's own max_connections reported by the status endpoint is /// a smaller backend limit the pooler multiplexes onto and does not constrain /// a client pool. #[serde(rename = "networkMaxConnections")] + #[serde(default = "default_network_max_connections")] pub network_max_connections: i64, /// Connection idle timeout in seconds. #[serde(rename = "networkIdleTimeoutSeconds")] + #[serde(default = "default_network_idle_timeout_seconds")] pub network_idle_timeout_seconds: i64, /// IP addresses/CIDR ranges allowed to connect. #[serde(rename = "networkIPAllowlist")] + #[serde(default = "default_network_ip_allowlist")] pub network_ip_allowlist: Vec, /// Whether automatic backups are enabled. #[serde(rename = "backupEnabled")] + #[serde(default = "default_backup_enabled")] pub backup_enabled: bool, /// Whether point-in-time recovery is enabled. #[serde(rename = "pitr")] + #[serde(default = "default_pitr")] pub pitr: bool, /// Number of days to retain PITR data. #[serde(rename = "pitrRetentionDays")] + #[serde(default = "default_pitr_retention_days")] pub pitr_retention_days: i64, /// Whether automatic storage expansion is enabled. #[serde(rename = "storageAutoscaling")] + #[serde(default = "default_storage_autoscaling")] pub storage_autoscaling: bool, /// Storage usage percentage that triggers automatic expansion. #[serde(rename = "storageAutoscalingThresholdPercent")] + #[serde(default = "default_storage_autoscaling_threshold_percent")] pub storage_autoscaling_threshold_percent: i64, - /// Maximum storage size in GB for autoscaling. 0 means no limit. + /// Maximum storage size in GB for autoscaling. Defaults to 3 times the + /// specification's storage. 0 means no limit. #[serde(rename = "storageAutoscalingMaxGb")] + #[serde(default = "default_storage_autoscaling_max_gb")] pub storage_autoscaling_max_gb: i64, /// Day of the week for the maintenance window. Possible values: sun, mon, tue, /// wed, thu, fri, sat. #[serde(rename = "maintenanceWindowDay")] + #[serde(default = "default_maintenance_window_day")] pub maintenance_window_day: String, /// Hour in UTC (0-23) when the maintenance window starts. #[serde(rename = "maintenanceWindowHourUtc")] + #[serde(default = "default_maintenance_window_hour_utc")] pub maintenance_window_hour_utc: i64, /// Whether metrics collection is enabled. #[serde(rename = "metricsEnabled")] + #[serde(default = "default_metrics_enabled")] pub metrics_enabled: bool, /// Whether the SQL API sidecar is enabled for this database. #[serde(rename = "sqlApiEnabled")] + #[serde(default = "default_sql_api_enabled")] pub sql_api_enabled: bool, /// Statement types accepted by the SQL API. Defaults to read/write DML only; /// DDL/DCL types (CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE) are opt-in per /// database. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, /// DROP, TRUNCATE, GRANT, REVOKE. #[serde(rename = "sqlApiAllowedStatements")] + #[serde(default = "default_sql_api_allowed_statements")] pub sql_api_allowed_statements: Vec, /// Maximum rows returned per SQL API execution. Results larger than this are /// truncated. #[serde(rename = "sqlApiMaxRows")] + #[serde(default = "default_sql_api_max_rows")] pub sql_api_max_rows: i64, /// Maximum serialised SQL API result payload in bytes. Results larger than /// this are truncated. #[serde(rename = "sqlApiMaxBytes")] + #[serde(default = "default_sql_api_max_bytes")] pub sql_api_max_bytes: i64, /// Maximum server-side SQL API execution time in seconds before the query is /// cancelled. #[serde(rename = "sqlApiTimeoutSeconds")] + #[serde(default = "default_sql_api_timeout_seconds")] pub sql_api_timeout_seconds: i64, /// Error message if status is failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_backend() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_connection_user() -> String { + "".to_string() +} + +fn default_connection_password() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_status() -> String { + "provisioning".to_string() +} + +fn default_container_status() -> String { + "".to_string() +} + +fn default_lifecycle_state() -> String { + "".to_string() +} + +fn default_idle_timeout_minutes() -> i64 { + 15 +} + +fn default_cpu() -> i64 { + 500 +} + +fn default_memory() -> i64 { + 512 +} + +fn default_storage() -> i64 { + 10 +} + +fn default_storage_status() -> String { + "idle".to_string() +} + +fn default_storage_target_gb() -> i64 { + 0 +} + +fn default_storage_class() -> String { + "ssd".to_string() +} + +fn default_storage_max_gb() -> i64 { + 0 +} + +fn default_node_pool() -> String { + "".to_string() +} + +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "".to_string() +} + +fn default_network_max_connections() -> i64 { + 100 +} + +fn default_network_idle_timeout_seconds() -> i64 { + 900 +} + +fn default_network_ip_allowlist() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_backup_enabled() -> bool { + true +} + +fn default_pitr() -> bool { + true +} + +fn default_pitr_retention_days() -> i64 { + 7 +} + +fn default_storage_autoscaling() -> bool { + true +} + +fn default_storage_autoscaling_threshold_percent() -> i64 { + 85 +} + +fn default_storage_autoscaling_max_gb() -> i64 { + 0 +} + +fn default_maintenance_window_day() -> String { + "sun".to_string() +} + +fn default_maintenance_window_hour_utc() -> i64 { + 3 +} + +fn default_metrics_enabled() -> bool { + false +} + +fn default_sql_api_enabled() -> bool { + true +} + +fn default_sql_api_allowed_statements() -> Vec { + serde_json::from_value(serde_json::json!(["SELECT", "INSERT", "UPDATE", "DELETE"])).unwrap() +} + +fn default_sql_api_max_rows() -> i64 { + 10000 +} + +fn default_sql_api_max_bytes() -> i64 { + 10485760 +} + +fn default_sql_api_timeout_seconds() -> i64 { + 30 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabase { /// Get id pub fn id(&self) -> &String { @@ -218,14 +446,26 @@ impl DedicatedDatabase { &self.name } + /// Set api + pub fn set_api(mut self, api: String) -> Self { + self.api = Some(api); + self + } + /// Get api - pub fn api(&self) -> &String { - &self.api + pub fn api(&self) -> Option<&String> { + self.api.as_ref() + } + + /// Set engine + pub fn set_engine(mut self, engine: String) -> Self { + self.engine = Some(engine); + self } /// Get engine - pub fn engine(&self) -> &String { - &self.engine + pub fn engine(&self) -> Option<&String> { + self.engine.as_ref() } /// Get version @@ -248,9 +488,15 @@ impl DedicatedDatabase { &self.hostname } + /// Set connection_port + pub fn set_connection_port(mut self, connection_port: i64) -> Self { + self.connection_port = Some(connection_port); + self + } + /// Get connection_port - pub fn connection_port(&self) -> &i64 { - &self.connection_port + pub fn connection_port(&self) -> Option<&i64> { + self.connection_port.as_ref() } /// Get connection_user @@ -263,9 +509,15 @@ impl DedicatedDatabase { &self.connection_password } + /// Set credential_generation + pub fn set_credential_generation(mut self, credential_generation: i64) -> Self { + self.credential_generation = Some(credential_generation); + self + } + /// Get credential_generation - pub fn credential_generation(&self) -> &i64 { - &self.credential_generation + pub fn credential_generation(&self) -> Option<&i64> { + self.credential_generation.as_ref() } /// Get connection_string @@ -335,26 +587,14 @@ impl DedicatedDatabase { &self.storage } - /// Set storage_status - pub fn set_storage_status(mut self, storage_status: String) -> Self { - self.storage_status = Some(storage_status); - self - } - /// Get storage_status - pub fn storage_status(&self) -> Option<&String> { - self.storage_status.as_ref() - } - - /// Set storage_target_gb - pub fn set_storage_target_gb(mut self, storage_target_gb: i64) -> Self { - self.storage_target_gb = Some(storage_target_gb); - self + pub fn storage_status(&self) -> &String { + &self.storage_status } /// Get storage_target_gb - pub fn storage_target_gb(&self) -> Option<&i64> { - self.storage_target_gb.as_ref() + pub fn storage_target_gb(&self) -> &i64 { + &self.storage_target_gb } /// Set storage_resize_started_at @@ -496,16 +736,12 @@ mod tests { let _ = _model.updated_at(); let _ = _model.project_id(); let _ = _model.name(); - let _ = _model.api(); - let _ = _model.engine(); let _ = _model.version(); let _ = _model.specification(); let _ = _model.backend(); let _ = _model.hostname(); - let _ = _model.connection_port(); let _ = _model.connection_user(); let _ = _model.connection_password(); - let _ = _model.credential_generation(); let _ = _model.connection_string(); let _ = _model.ssl(); let _ = _model.status(); @@ -515,6 +751,8 @@ mod tests { let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.storage(); + let _ = _model.storage_status(); + let _ = _model.storage_target_gb(); let _ = _model.storage_class(); let _ = _model.storage_max_gb(); let _ = _model.node_pool(); diff --git a/src/models/dedicated_database_backup.rs b/src/models/dedicated_database_backup.rs index 703d3d6..cef73b2 100644 --- a/src/models/dedicated_database_backup.rs +++ b/src/models/dedicated_database_backup.rs @@ -8,44 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackup { /// Backup ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID this backup belongs to. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup policy ID when the backup was created by a schedule. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// Backup trigger. Possible values: manual, schedule. #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup), wal (write-ahead log continuous /// archival). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Backup type that was requested. Differs from `type` when the backend could /// not run the requested type and took a different one instead, in which case /// `fallbackReason` explains why. Empty for backups taken before the requested /// type was recorded. #[serde(rename = "requestedType")] + #[serde(default = "default_requested_type")] pub requested_type: String, /// Why the backend ran a different backup type than the one requested. Empty /// when the backup ran as requested. #[serde(rename = "fallbackReason")] + #[serde(default = "default_fallback_reason")] pub fallback_reason: String, /// Backup status. Possible values: pending (queued for processing), running /// (currently in progress), completed (successfully finished), failed /// (encountered an error), verified (integrity check passed). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Backup size in bytes. #[serde(rename = "sizeBytes")] + #[serde(default = "default_size_bytes")] pub size_bytes: i64, /// Backup start time in ISO 8601 format. #[serde(rename = "startedAt")] @@ -73,9 +84,58 @@ pub struct DedicatedDatabaseBackup { pub log_position: Option, /// Error message if backup failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "manual".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_requested_type() -> String { + "".to_string() +} + +fn default_fallback_reason() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_size_bytes() -> i64 { + 0 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseBackup { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_backup_list.rs b/src/models/dedicated_database_backup_list.rs index 4833b14..7f173ad 100644 --- a/src/models/dedicated_database_backup_list.rs +++ b/src/models/dedicated_database_backup_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackupList { /// Total number of backups. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of backups. #[serde(rename = "backups")] + #[serde(default = "default_backups")] pub backups: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_backups() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBackupList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_backup_storage.rs b/src/models/dedicated_database_backup_storage.rs index 395e376..6756910 100644 --- a/src/models/dedicated_database_backup_storage.rs +++ b/src/models/dedicated_database_backup_storage.rs @@ -9,21 +9,46 @@ pub struct DedicatedDatabaseBackupStorage { /// Storage provider. Possible values: s3 (Amazon S3 or S3-compatible), gcs /// (Google Cloud Storage), azure (Azure Blob Storage). #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Storage bucket or container name. #[serde(rename = "bucket")] + #[serde(default = "default_bucket")] pub bucket: String, /// Storage region. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// Object key prefix for backups. #[serde(rename = "prefix")] + #[serde(default = "default_prefix")] pub prefix: String, /// Custom endpoint for S3-compatible storage. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_provider() -> String { + "".to_string() +} + +fn default_bucket() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_prefix() -> String { + "backups/".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl DedicatedDatabaseBackupStorage { /// Get provider pub fn provider(&self) -> &String { diff --git a/src/models/dedicated_database_branch.rs b/src/models/dedicated_database_branch.rs index db3bc19..6d283bf 100644 --- a/src/models/dedicated_database_branch.rs +++ b/src/models/dedicated_database_branch.rs @@ -8,43 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranch { /// Branch identifier. #[serde(rename = "branchId")] + #[serde(default = "default_branch_id")] pub branch_id: String, /// Branch name. #[serde(rename = "branchName")] + #[serde(default = "default_branch_name")] pub branch_name: String, /// Kubernetes namespace where the branch is deployed. #[serde(rename = "namespace")] + #[serde(default = "default_namespace")] pub namespace: String, /// Unix timestamp when the branch expires. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: i64, /// Branch hostname for direct connections. #[serde(rename = "host")] + #[serde(default = "default_host")] pub host: String, /// Branch port. Null until the backing reports one. #[serde(rename = "port")] - pub port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub port: Option, /// Advertised catalog the client connects to. MySQL/MariaDB use default; /// Postgres uses the routing label. #[serde(rename = "database")] + #[serde(default = "default_database")] pub database: String, /// Database username. Shared with the parent database. #[serde(rename = "username")] + #[serde(default = "default_username")] pub username: String, /// Database password. Shared with the parent database. #[serde(rename = "password")] + #[serde(default = "default_password")] pub password: String, /// Whether SSL is required. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database engine. Possible values: postgresql, mysql, mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Full connection string for the branch. #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, } +fn default_branch_id() -> String { + "".to_string() +} + +fn default_branch_name() -> String { + "".to_string() +} + +fn default_namespace() -> String { + "".to_string() +} + +fn default_expires_at() -> i64 { + 0 +} + +fn default_host() -> String { + "".to_string() +} + +fn default_database() -> String { + "".to_string() +} + +fn default_username() -> String { + "".to_string() +} + +fn default_password() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_engine() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + impl DedicatedDatabaseBranch { /// Get branch_id pub fn branch_id(&self) -> &String { @@ -71,9 +127,15 @@ impl DedicatedDatabaseBranch { &self.host } + /// Set port + pub fn set_port(mut self, port: i64) -> Self { + self.port = Some(port); + self + } + /// Get port - pub fn port(&self) -> &i64 { - &self.port + pub fn port(&self) -> Option<&i64> { + self.port.as_ref() } /// Get database @@ -119,7 +181,6 @@ mod tests { let _ = _model.namespace(); let _ = _model.expires_at(); let _ = _model.host(); - let _ = _model.port(); let _ = _model.database(); let _ = _model.username(); let _ = _model.password(); diff --git a/src/models/dedicated_database_branch_list.rs b/src/models/dedicated_database_branch_list.rs index 50da757..adb1575 100644 --- a/src/models/dedicated_database_branch_list.rs +++ b/src/models/dedicated_database_branch_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranchList { /// Total number of branches. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of branches. #[serde(rename = "branches")] + #[serde(default = "default_branches")] pub branches: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBranchList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_execution.rs b/src/models/dedicated_database_execution.rs index cbd430a..5998d80 100644 --- a/src/models/dedicated_database_execution.rs +++ b/src/models/dedicated_database_execution.rs @@ -9,26 +9,56 @@ pub struct DedicatedDatabaseExecution { /// Result rows as a list of column-name => value maps. Empty for non-returning /// statements. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, /// Number of rows returned (for SELECT) or affected (for /// INSERT/UPDATE/DELETE). #[serde(rename = "rowCount")] + #[serde(default = "default_row_count")] pub row_count: i64, /// Column metadata in result-set order. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Server-side execution time in milliseconds. #[serde(rename = "durationMs")] + #[serde(default = "default_duration_ms")] pub duration_ms: i64, /// True when the configured row or byte cap was hit and the result was /// truncated. #[serde(rename = "truncated")] + #[serde(default = "default_truncated")] pub truncated: bool, /// Serialised payload size in bytes. #[serde(rename = "bytes")] + #[serde(default = "default_bytes")] pub bytes: i64, } +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_row_count() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_duration_ms() -> i64 { + 0 +} + +fn default_truncated() -> bool { + false +} + +fn default_bytes() -> i64 { + 0 +} + impl DedicatedDatabaseExecution { /// Get rows pub fn rows(&self) -> &Vec { diff --git a/src/models/dedicated_database_execution_column.rs b/src/models/dedicated_database_execution_column.rs index 0ec270d..4ceffeb 100644 --- a/src/models/dedicated_database_execution_column.rs +++ b/src/models/dedicated_database_execution_column.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExecutionColumn { /// Column name as returned by the database. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Engine-specific column type (e.g. int4, text, timestamptz). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + impl DedicatedDatabaseExecutionColumn { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/dedicated_database_extensions.rs b/src/models/dedicated_database_extensions.rs index eefa389..a1a9d2f 100644 --- a/src/models/dedicated_database_extensions.rs +++ b/src/models/dedicated_database_extensions.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExtensions { /// List of installed extensions. #[serde(rename = "installed")] + #[serde(default = "default_installed")] pub installed: Vec, /// List of available extensions that can be installed. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: Vec, /// Curated metadata (display name, description, category) for each available /// extension. #[serde(rename = "metadata")] + #[serde(default = "default_metadata")] pub metadata: Vec, } +fn default_installed() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_available() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_metadata() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseExtensions { /// Get installed pub fn installed(&self) -> &Vec { diff --git a/src/models/dedicated_database_list.rs b/src/models/dedicated_database_list.rs index 7c68b07..40a0892 100644 --- a/src/models/dedicated_database_list.rs +++ b/src/models/dedicated_database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_member.rs b/src/models/dedicated_database_member.rs index df7f0d1..9ab4fee 100644 --- a/src/models/dedicated_database_member.rs +++ b/src/models/dedicated_database_member.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseMember { /// Member identifier. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology and this member has not /// been probed, so no member can be named the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Member pod status. Possible values: pending (configured but absent from the /// backend topology, so nothing is bringing it up), provisioning (pod missing @@ -21,6 +23,7 @@ pub struct DedicatedDatabaseMember { /// failed (Failed phase or CrashLoopBackOff container), or the lowercased pod /// phase reported by the cluster. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -41,6 +44,18 @@ pub struct DedicatedDatabaseMember { pub lag_seconds: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl DedicatedDatabaseMember { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation.rs b/src/models/dedicated_database_operation.rs index 4476b00..02c317c 100644 --- a/src/models/dedicated_database_operation.rs +++ b/src/models/dedicated_database_operation.rs @@ -8,24 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperation { /// Operation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Operation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID the operation ran against. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Operation type, such as provision, update, credentials-update, restore, /// pausing, resuming, failover, backup-create or cross-region-enable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Operation status. Possible values: queued (accepted and waiting to resume), /// running (in progress), completed (finished successfully), failed (ended in /// an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of times this operation has been attempted. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, /// Time the operation was requested, in ISO 8601 format. #[serde(rename = "requestedAt")] @@ -42,12 +48,46 @@ pub struct DedicatedDatabaseOperation { /// Machine-readable failure code. `Interrupted` marks an attempt that ended /// before its outcome could be confirmed. #[serde(rename = "errorCode")] + #[serde(default = "default_error_code")] pub error_code: String, /// Failure message if the operation failed. #[serde(rename = "errorMessage")] + #[serde(default = "default_error_message")] pub error_message: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + +fn default_error_code() -> String { + "".to_string() +} + +fn default_error_message() -> String { + "".to_string() +} + impl DedicatedDatabaseOperation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation_list.rs b/src/models/dedicated_database_operation_list.rs index 641721c..de4eb57 100644 --- a/src/models/dedicated_database_operation_list.rs +++ b/src/models/dedicated_database_operation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperationList { /// Total number of operations. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of operations. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_operations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseOperationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_pitr_windows.rs b/src/models/dedicated_database_pitr_windows.rs index 52b2fe5..59240b4 100644 --- a/src/models/dedicated_database_pitr_windows.rs +++ b/src/models/dedicated_database_pitr_windows.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePITRWindows { /// Earliest available recovery point. #[serde(rename = "earliest")] + #[serde(default = "default_earliest")] pub earliest: String, /// Latest available recovery point. #[serde(rename = "latest")] + #[serde(default = "default_latest")] pub latest: String, } +fn default_earliest() -> String { + "".to_string() +} + +fn default_latest() -> String { + "".to_string() +} + impl DedicatedDatabasePITRWindows { /// Get earliest pub fn earliest(&self) -> &String { diff --git a/src/models/dedicated_database_pooler.rs b/src/models/dedicated_database_pooler.rs index d1fa674..2d23de5 100644 --- a/src/models/dedicated_database_pooler.rs +++ b/src/models/dedicated_database_pooler.rs @@ -8,49 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePooler { /// Whether connection pooling is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Connection pool mode. Possible values: transaction (releases connections /// back to pool after each transaction), session (holds connections for the /// entire client session). #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Client-connection ceiling the pooler accepts. Enforced on MySQL and /// MariaDB; on PostgreSQL the pooler has no client cap, so this reports the /// database's advertised networkMaxConnections and cannot be set here. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Default pool size per user. #[serde(rename = "defaultPoolSize")] + #[serde(default = "default_default_pool_size")] pub default_pool_size: i64, /// Pooler listening port. #[serde(rename = "port")] + #[serde(default = "default_port")] pub port: i64, /// Whether SELECTs are routed to HA replicas while writes and locked reads /// stay on the primary. Active only when HA is enabled. #[serde(rename = "readWriteSplitting")] + #[serde(default = "default_read_write_splitting")] pub read_write_splitting: bool, /// Effective CPU request applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (5% of DB CPU, floor 100m) /// unless overridden. #[serde(rename = "poolerCpuRequest")] + #[serde(default = "default_pooler_cpu_request")] pub pooler_cpu_request: String, /// Effective CPU limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (10% of DB CPU, floor 200m) /// unless overridden. #[serde(rename = "poolerCpuLimit")] + #[serde(default = "default_pooler_cpu_limit")] pub pooler_cpu_limit: String, /// Effective memory request applied to the pooler sidecar container /// (Kubernetes quantity). Returns the proportional default (7.5% of DB memory, /// floor 64Mi) unless overridden. #[serde(rename = "poolerMemoryRequest")] + #[serde(default = "default_pooler_memory_request")] pub pooler_memory_request: String, /// Effective memory limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (15% of DB memory, floor 128Mi) /// unless overridden. #[serde(rename = "poolerMemoryLimit")] + #[serde(default = "default_pooler_memory_limit")] pub pooler_memory_limit: String, } +fn default_enabled() -> bool { + false +} + +fn default_mode() -> String { + "transaction".to_string() +} + +fn default_max_connections() -> i64 { + 100 +} + +fn default_default_pool_size() -> i64 { + 20 +} + +fn default_port() -> i64 { + 6432 +} + +fn default_read_write_splitting() -> bool { + false +} + +fn default_pooler_cpu_request() -> String { + "".to_string() +} + +fn default_pooler_cpu_limit() -> String { + "".to_string() +} + +fn default_pooler_memory_request() -> String { + "".to_string() +} + +fn default_pooler_memory_limit() -> String { + "".to_string() +} + impl DedicatedDatabasePooler { /// Get enabled pub fn enabled(&self) -> &bool { diff --git a/src/models/dedicated_database_replicas.rs b/src/models/dedicated_database_replicas.rs index 24bd468..701d8cc 100644 --- a/src/models/dedicated_database_replicas.rs +++ b/src/models/dedicated_database_replicas.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseReplicas { /// Number of configured replicas. Zero means high availability is disabled. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Requested replication sync mode. Possible values: async (asynchronous, /// fastest), sync (synchronous, strong consistency), quorum (quorum-based, /// majority of replicas must confirm). This is what was asked for; compare it /// with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. A value below the @@ -24,13 +26,16 @@ pub struct DedicatedDatabaseReplicas { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. Zero means writes are acknowledged locally. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -48,9 +53,34 @@ pub struct DedicatedDatabaseReplicas { pub sync_state_confirmed: Option, /// Per-pod statuses for the primary and every replica. #[serde(rename = "members")] + #[serde(default = "default_members")] pub members: Vec, } +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_members() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseReplicas { /// Get replicas pub fn replicas(&self) -> &i64 { diff --git a/src/models/dedicated_database_restoration.rs b/src/models/dedicated_database_restoration.rs index e52fefd..2ebee2e 100644 --- a/src/models/dedicated_database_restoration.rs +++ b/src/models/dedicated_database_restoration.rs @@ -8,45 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID being restored into. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Source database ID when restoring a backup into another database. #[serde(rename = "sourceDatabaseId")] - pub source_database_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_database_id: Option, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup ID used for restoration (null for PITR). #[serde(rename = "backupId")] - pub backup_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub backup_id: Option, /// Restoration type. Possible values: backup (restore from a specific backup /// snapshot), pitr (point-in-time recovery to a specific timestamp). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Restoration status. Possible values: pending (queued for processing), /// running (currently in progress), completed (successfully finished), failed /// (encountered an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Target time for PITR restoration in ISO 8601 format. #[serde(rename = "targetTime")] - pub target_time: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_time: Option, /// Restoration start time in ISO 8601 format. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Restoration completion time in ISO 8601 format. #[serde(rename = "completedAt")] - pub completed_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub completed_at: Option, /// Error message if restoration failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "backup".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseRestoration { /// Get id pub fn id(&self) -> &String { @@ -63,9 +103,15 @@ impl DedicatedDatabaseRestoration { &self.database_id } + /// Set source_database_id + pub fn set_source_database_id(mut self, source_database_id: String) -> Self { + self.source_database_id = Some(source_database_id); + self + } + /// Get source_database_id - pub fn source_database_id(&self) -> &String { - &self.source_database_id + pub fn source_database_id(&self) -> Option<&String> { + self.source_database_id.as_ref() } /// Get project_id @@ -73,9 +119,15 @@ impl DedicatedDatabaseRestoration { &self.project_id } + /// Set backup_id + pub fn set_backup_id(mut self, backup_id: String) -> Self { + self.backup_id = Some(backup_id); + self + } + /// Get backup_id - pub fn backup_id(&self) -> &String { - &self.backup_id + pub fn backup_id(&self) -> Option<&String> { + self.backup_id.as_ref() } /// Get r#type @@ -88,19 +140,37 @@ impl DedicatedDatabaseRestoration { &self.status } + /// Set target_time + pub fn set_target_time(mut self, target_time: String) -> Self { + self.target_time = Some(target_time); + self + } + /// Get target_time - pub fn target_time(&self) -> &String { - &self.target_time + pub fn target_time(&self) -> Option<&String> { + self.target_time.as_ref() + } + + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self } /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() + } + + /// Set completed_at + pub fn set_completed_at(mut self, completed_at: String) -> Self { + self.completed_at = Some(completed_at); + self } /// Get completed_at - pub fn completed_at(&self) -> &String { - &self.completed_at + pub fn completed_at(&self) -> Option<&String> { + self.completed_at.as_ref() } /// Get error @@ -119,14 +189,9 @@ mod tests { let _ = _model.id(); let _ = _model.created_at(); let _ = _model.database_id(); - let _ = _model.source_database_id(); let _ = _model.project_id(); - let _ = _model.backup_id(); let _ = _model.r#type(); let _ = _model.status(); - let _ = _model.target_time(); - let _ = _model.started_at(); - let _ = _model.completed_at(); let _ = _model.error(); } diff --git a/src/models/dedicated_database_restoration_list.rs b/src/models/dedicated_database_restoration_list.rs index 3d24d00..170ff62 100644 --- a/src/models/dedicated_database_restoration_list.rs +++ b/src/models/dedicated_database_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_specification.rs b/src/models/dedicated_database_specification.rs index 7dab746..f2bc9ee 100644 --- a/src/models/dedicated_database_specification.rs +++ b/src/models/dedicated_database_specification.rs @@ -8,49 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecification { /// Specification slug. Use this value when creating a dedicated database. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, /// Human readable specification name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Monthly price of the specification in USD. #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Price per GB of storage above the included amount, per month, in USD. #[serde(rename = "storageOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_overage_rate: Option, + #[serde(default = "default_storage_overage_rate")] + pub storage_overage_rate: f64, /// Price per GB of bandwidth above the included amount, per month, in USD. #[serde(rename = "bandwidthOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub bandwidth_overage_rate: Option, + #[serde(default = "default_bandwidth_overage_rate")] + pub bandwidth_overage_rate: f64, /// High availability replica price as a fraction of the specification price. #[serde(rename = "replicaRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub replica_rate: Option, + #[serde(default = "default_replica_rate")] + pub replica_rate: f64, /// Point-in-time recovery price as a fraction of the specification price. #[serde(rename = "pitrRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pitr_rate: Option, + #[serde(default = "default_pitr_rate")] + pub pitr_rate: f64, /// Allocated CPU in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Allocated memory in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Maximum number of concurrent connections. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Included storage in GB before overage charges apply. #[serde(rename = "includedStorage")] + #[serde(default = "default_included_storage")] pub included_storage: i64, /// Included bandwidth in GB before overage charges apply. #[serde(rename = "includedBandwidth")] + #[serde(default = "default_included_bandwidth")] pub included_bandwidth: i64, /// Whether the specification is available on the current plan. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_slug() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_storage_overage_rate() -> f64 { + 0.0 +} + +fn default_bandwidth_overage_rate() -> f64 { + 0.0 +} + +fn default_replica_rate() -> f64 { + 0.0 +} + +fn default_pitr_rate() -> f64 { + 0.0 +} + +fn default_cpu() -> i64 { + 0 +} + +fn default_memory() -> i64 { + 0 +} + +fn default_max_connections() -> i64 { + 0 +} + +fn default_included_storage() -> i64 { + 0 +} + +fn default_included_bandwidth() -> i64 { + 0 +} + +fn default_enabled() -> bool { + false +} + impl DedicatedDatabaseSpecification { /// Get slug pub fn slug(&self) -> &String { @@ -67,48 +128,24 @@ impl DedicatedDatabaseSpecification { &self.price } - /// Set storage_overage_rate - pub fn set_storage_overage_rate(mut self, storage_overage_rate: f64) -> Self { - self.storage_overage_rate = Some(storage_overage_rate); - self - } - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> Option<&f64> { - self.storage_overage_rate.as_ref() - } - - /// Set bandwidth_overage_rate - pub fn set_bandwidth_overage_rate(mut self, bandwidth_overage_rate: f64) -> Self { - self.bandwidth_overage_rate = Some(bandwidth_overage_rate); - self + pub fn storage_overage_rate(&self) -> &f64 { + &self.storage_overage_rate } /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> Option<&f64> { - self.bandwidth_overage_rate.as_ref() - } - - /// Set replica_rate - pub fn set_replica_rate(mut self, replica_rate: f64) -> Self { - self.replica_rate = Some(replica_rate); - self + pub fn bandwidth_overage_rate(&self) -> &f64 { + &self.bandwidth_overage_rate } /// Get replica_rate - pub fn replica_rate(&self) -> Option<&f64> { - self.replica_rate.as_ref() - } - - /// Set pitr_rate - pub fn set_pitr_rate(mut self, pitr_rate: f64) -> Self { - self.pitr_rate = Some(pitr_rate); - self + pub fn replica_rate(&self) -> &f64 { + &self.replica_rate } /// Get pitr_rate - pub fn pitr_rate(&self) -> Option<&f64> { - self.pitr_rate.as_ref() + pub fn pitr_rate(&self) -> &f64 { + &self.pitr_rate } /// Get cpu @@ -152,6 +189,10 @@ mod tests { let _ = _model.slug(); let _ = _model.name(); let _ = _model.price(); + let _ = _model.storage_overage_rate(); + let _ = _model.bandwidth_overage_rate(); + let _ = _model.replica_rate(); + let _ = _model.pitr_rate(); let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.max_connections(); diff --git a/src/models/dedicated_database_specification_list.rs b/src/models/dedicated_database_specification_list.rs index 2be3453..e86f829 100644 --- a/src/models/dedicated_database_specification_list.rs +++ b/src/models/dedicated_database_specification_list.rs @@ -8,13 +8,20 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecificationList { /// List of dedicated database specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, /// Total number of specifications. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, - /// Overage and add-on pricing shared across all specifications. - #[serde(rename = "pricing")] - pub pricing: crate::models::DedicatedDatabaseSpecificationPricing, +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_total() -> i64 { + 0 } impl DedicatedDatabaseSpecificationList { @@ -27,11 +34,6 @@ impl DedicatedDatabaseSpecificationList { pub fn total(&self) -> &i64 { &self.total } - - /// Get pricing - pub fn pricing(&self) -> &crate::models::DedicatedDatabaseSpecificationPricing { - &self.pricing - } } #[cfg(test)] @@ -43,7 +45,6 @@ mod tests { let _model = ::default(); let _ = _model.specifications(); let _ = _model.total(); - let _ = _model.pricing(); } #[test] diff --git a/src/models/dedicated_database_specification_pricing.rs b/src/models/dedicated_database_specification_pricing.rs deleted file mode 100644 index 0842526..0000000 --- a/src/models/dedicated_database_specification_pricing.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! DedicatedDatabaseSpecificationPricing model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// SpecificationPricing -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DedicatedDatabaseSpecificationPricing { - /// Price per GB of storage above the included amount, per month, in USD. - #[serde(rename = "storageOverageRate")] - pub storage_overage_rate: f64, - /// Price per GB of bandwidth above the included amount, per month, in USD. - #[serde(rename = "bandwidthOverageRate")] - pub bandwidth_overage_rate: f64, - /// High availability replica price as a fraction of the specification cost. - #[serde(rename = "replicaRate")] - pub replica_rate: f64, - /// Point-in-time recovery price as a fraction of the specification cost. - #[serde(rename = "pitrRate")] - pub pitr_rate: f64, -} - -impl DedicatedDatabaseSpecificationPricing { - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> &f64 { - &self.storage_overage_rate - } - - /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> &f64 { - &self.bandwidth_overage_rate - } - - /// Get replica_rate - pub fn replica_rate(&self) -> &f64 { - &self.replica_rate - } - - /// Get pitr_rate - pub fn pitr_rate(&self) -> &f64 { - &self.pitr_rate - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dedicated_database_specification_pricing_creation() { - let _model = ::default(); - let _ = _model.storage_overage_rate(); - let _ = _model.bandwidth_overage_rate(); - let _ = _model.replica_rate(); - let _ = _model.pitr_rate(); - } - - #[test] - fn test_dedicated_database_specification_pricing_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = - serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/deployment.rs b/src/models/deployment.rs index 2da7e6f..78539b5 100644 --- a/src/models/deployment.rs +++ b/src/models/deployment.rs @@ -8,45 +8,59 @@ use serde::{Deserialize, Serialize}; pub struct Deployment { /// Deployment ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Deployment creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Deployment update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Type of deployment. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// The entrypoint file to use to execute the deployment code. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The code size in bytes. #[serde(rename = "sourceSize")] + #[serde(default = "default_source_size")] pub source_size: i64, /// The build output size in bytes. #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// The total size in bytes (source and build output). #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, /// The current build ID. #[serde(rename = "buildId")] + #[serde(default = "default_build_id")] pub build_id: String, /// Whether the deployment should be automatically activated. #[serde(rename = "activate")] + #[serde(default = "default_activate")] pub activate: bool, /// Screenshot with light theme preference file ID. #[serde(rename = "screenshotLight")] + #[serde(default = "default_screenshot_light")] pub screenshot_light: String, /// Screenshot with dark theme preference file ID. #[serde(rename = "screenshotDark")] + #[serde(default = "default_screenshot_dark")] pub screenshot_dark: String, /// The deployment status. Possible values are "waiting", "processing", /// "building", "ready", "canceled" and "failed". @@ -54,42 +68,158 @@ pub struct Deployment { pub status: crate::enums::DeploymentStatus, /// The build logs. #[serde(rename = "buildLogs")] + #[serde(default = "default_build_logs")] pub build_logs: String, /// The current build time in seconds. #[serde(rename = "buildDuration")] + #[serde(default = "default_build_duration")] pub build_duration: i64, /// The name of the vcs provider repository #[serde(rename = "providerRepositoryName")] + #[serde(default = "default_provider_repository_name")] pub provider_repository_name: String, /// The name of the vcs provider repository owner #[serde(rename = "providerRepositoryOwner")] + #[serde(default = "default_provider_repository_owner")] pub provider_repository_owner: String, /// The url of the vcs provider repository #[serde(rename = "providerRepositoryUrl")] + #[serde(default = "default_provider_repository_url")] pub provider_repository_url: String, /// The commit hash of the vcs commit #[serde(rename = "providerCommitHash")] + #[serde(default = "default_provider_commit_hash")] pub provider_commit_hash: String, /// The url of vcs commit author #[serde(rename = "providerCommitAuthorUrl")] + #[serde(default = "default_provider_commit_author_url")] pub provider_commit_author_url: String, /// The name of vcs commit author #[serde(rename = "providerCommitAuthor")] + #[serde(default = "default_provider_commit_author")] pub provider_commit_author: String, /// The commit message #[serde(rename = "providerCommitMessage")] + #[serde(default = "default_provider_commit_message")] pub provider_commit_message: String, /// The url of the vcs commit #[serde(rename = "providerCommitUrl")] + #[serde(default = "default_provider_commit_url")] pub provider_commit_url: String, /// The branch of the vcs repository #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// The branch of the vcs repository #[serde(rename = "providerBranchUrl")] + #[serde(default = "default_provider_branch_url")] pub provider_branch_url: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_source_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_total_size() -> i64 { + 0 +} + +fn default_build_id() -> String { + "".to_string() +} + +fn default_activate() -> bool { + false +} + +fn default_screenshot_light() -> String { + "".to_string() +} + +fn default_screenshot_dark() -> String { + "".to_string() +} + +fn default_build_logs() -> String { + "".to_string() +} + +fn default_build_duration() -> i64 { + 0 +} + +fn default_provider_repository_name() -> String { + "".to_string() +} + +fn default_provider_repository_owner() -> String { + "".to_string() +} + +fn default_provider_repository_url() -> String { + "".to_string() +} + +fn default_provider_commit_hash() -> String { + "".to_string() +} + +fn default_provider_commit_author_url() -> String { + "".to_string() +} + +fn default_provider_commit_author() -> String { + "".to_string() +} + +fn default_provider_commit_message() -> String { + "".to_string() +} + +fn default_provider_commit_url() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_branch_url() -> String { + "".to_string() +} + impl Deployment { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/deployment_list.rs b/src/models/deployment_list.rs index 5ee6ea7..f58b0b2 100644 --- a/src/models/deployment_list.rs +++ b/src/models/deployment_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DeploymentList { /// Total number of deployments that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of deployments. #[serde(rename = "deployments")] + #[serde(default = "default_deployments")] pub deployments: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_deployments() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DeploymentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dev_key.rs b/src/models/dev_key.rs deleted file mode 100644 index 7b5ba1f..0000000 --- a/src/models/dev_key.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! DevKey model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// DevKey -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DevKey { - /// Key ID. - #[serde(rename = "$id")] - pub id: String, - /// Key creation date in ISO 8601 format. - #[serde(rename = "$createdAt")] - pub created_at: String, - /// Key update date in ISO 8601 format. - #[serde(rename = "$updatedAt")] - pub updated_at: String, - /// Key name. - #[serde(rename = "name")] - pub name: String, - /// Key expiration date in ISO 8601 format. - #[serde(rename = "expire")] - pub expire: String, - /// Secret key. - #[serde(rename = "secret")] - pub secret: String, - /// Most recent access date in ISO 8601 format. This attribute is only updated - /// again after 24 hours. - #[serde(rename = "accessedAt")] - pub accessed_at: String, - /// List of SDK user agents that used this key. - #[serde(rename = "sdks")] - pub sdks: Vec, -} - -impl DevKey { - /// Get id - pub fn id(&self) -> &String { - &self.id - } - - /// Get created_at - pub fn created_at(&self) -> &String { - &self.created_at - } - - /// Get updated_at - pub fn updated_at(&self) -> &String { - &self.updated_at - } - - /// Get name - pub fn name(&self) -> &String { - &self.name - } - - /// Get expire - pub fn expire(&self) -> &String { - &self.expire - } - - /// Get secret - pub fn secret(&self) -> &String { - &self.secret - } - - /// Get accessed_at - pub fn accessed_at(&self) -> &String { - &self.accessed_at - } - - /// Get sdks - pub fn sdks(&self) -> &Vec { - &self.sdks - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dev_key_creation() { - let _model = ::default(); - let _ = _model.id(); - let _ = _model.created_at(); - let _ = _model.updated_at(); - let _ = _model.name(); - let _ = _model.expire(); - let _ = _model.secret(); - let _ = _model.accessed_at(); - let _ = _model.sdks(); - } - - #[test] - fn test_dev_key_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/document.rs b/src/models/document.rs index 67c4a9c..0976976 100644 --- a/src/models/document.rs +++ b/src/models/document.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Document { /// Document ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Document sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Collection ID. #[serde(rename = "$collectionId")] + #[serde(default = "default_collection_id")] pub collection_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Document creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Document update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Document permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_collection_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Document { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/document_list.rs b/src/models/document_list.rs index bf9ba60..55f3143 100644 --- a/src/models/document_list.rs +++ b/src/models/document_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DocumentList { /// Total number of documents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of documents. #[serde(rename = "documents")] + #[serde(default = "default_documents")] pub documents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_documents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DocumentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/email_template.rs b/src/models/email_template.rs index 3236650..4ff064a 100644 --- a/src/models/email_template.rs +++ b/src/models/email_template.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplate { /// Template type #[serde(rename = "templateId")] + #[serde(default = "default_template_id")] pub template_id: String, /// Template locale #[serde(rename = "locale")] + #[serde(default = "default_locale")] pub locale: String, /// Template message #[serde(rename = "message")] + #[serde(default = "default_message")] pub message: String, /// Name of the sender #[serde(rename = "senderName")] + #[serde(default = "default_sender_name")] pub sender_name: String, /// Email of the sender #[serde(rename = "senderEmail")] + #[serde(default = "default_sender_email")] pub sender_email: String, /// Reply to email address #[serde(rename = "replyToEmail")] + #[serde(default = "default_reply_to_email")] pub reply_to_email: String, /// Reply to name #[serde(rename = "replyToName")] + #[serde(default = "default_reply_to_name")] pub reply_to_name: String, /// Email subject #[serde(rename = "subject")] + #[serde(default = "default_subject")] pub subject: String, } +fn default_template_id() -> String { + "".to_string() +} + +fn default_locale() -> String { + "".to_string() +} + +fn default_message() -> String { + "".to_string() +} + +fn default_sender_name() -> String { + "".to_string() +} + +fn default_sender_email() -> String { + "".to_string() +} + +fn default_reply_to_email() -> String { + "".to_string() +} + +fn default_reply_to_name() -> String { + "".to_string() +} + +fn default_subject() -> String { + "".to_string() +} + impl EmailTemplate { /// Get template_id pub fn template_id(&self) -> &String { diff --git a/src/models/email_template_list.rs b/src/models/email_template_list.rs index 02dbf9a..6d93da2 100644 --- a/src/models/email_template_list.rs +++ b/src/models/email_template_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplateList { /// Total number of templates that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of templates. #[serde(rename = "templates")] + #[serde(default = "default_templates")] pub templates: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_templates() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmailTemplateList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/embedding.rs b/src/models/embedding.rs index 1e26677..041e14d 100644 --- a/src/models/embedding.rs +++ b/src/models/embedding.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Embedding { /// Embedding model used to generate embeddings. #[serde(rename = "model")] + #[serde(default = "default_model")] pub model: String, /// Number of dimensions for each embedding vector. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, /// Embedding vector values. If an error occurs, this will be an empty array. #[serde(rename = "embedding")] + #[serde(default = "default_embedding")] pub embedding: Vec, /// Error message if embedding generation fails. Empty string if no error. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_model() -> String { + "".to_string() +} + +fn default_dimension() -> i64 { + 0 +} + +fn default_embedding() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_error() -> String { + "".to_string() +} + impl Embedding { /// Get model pub fn model(&self) -> &String { diff --git a/src/models/embedding_list.rs b/src/models/embedding_list.rs index 65f3074..25c9cbf 100644 --- a/src/models/embedding_list.rs +++ b/src/models/embedding_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmbeddingList { /// Total number of embeddings that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of embeddings. #[serde(rename = "embeddings")] + #[serde(default = "default_embeddings")] pub embeddings: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_embeddings() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmbeddingList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/ephemeral_key.rs b/src/models/ephemeral_key.rs index 091da9c..6abef19 100644 --- a/src/models/ephemeral_key.rs +++ b/src/models/ephemeral_key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct EphemeralKey { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EphemeralKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution.rs b/src/models/execution.rs index 9591343..46e3963 100644 --- a/src/models/execution.rs +++ b/src/models/execution.rs @@ -8,24 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Execution { /// Execution ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Execution creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Execution update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution roles. #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Function or site ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Execution resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: crate::enums::ExecutionResourceType, /// Deployment ID used to create the execution. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// The trigger that caused the resource to execute. Possible values can be: /// `http`, `schedule`, or `event`. @@ -37,39 +44,48 @@ pub struct Execution { pub status: crate::enums::ExecutionStatus, /// HTTP request method type. #[serde(rename = "requestMethod")] + #[serde(default = "default_request_method")] pub request_method: String, /// HTTP request path and query. #[serde(rename = "requestPath")] + #[serde(default = "default_request_path")] pub request_path: String, /// HTTP request headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "requestHeaders")] + #[serde(default = "default_request_headers")] pub request_headers: Vec, /// HTTP response status code. #[serde(rename = "responseStatusCode")] + #[serde(default = "default_response_status_code")] pub response_status_code: i64, /// HTTP response body. This will return empty unless execution is created as /// synchronous. #[serde(rename = "responseBody")] + #[serde(default = "default_response_body")] pub response_body: String, /// HTTP response headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "responseHeaders")] + #[serde(default = "default_response_headers")] pub response_headers: Vec, /// Resource logs. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Resource errors. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "errors")] + #[serde(default = "default_errors")] pub errors: String, - /// Resource(function/site) execution duration in seconds. + /// Total time the resource(function/site) took to respond, in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: f64, /// The scheduled time for execution. If left empty, execution will be queued /// immediately. @@ -78,6 +94,70 @@ pub struct Execution { pub scheduled_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> crate::enums::ExecutionResourceType { + serde_json::from_value(serde_json::json!("functions")).unwrap() +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_request_method() -> String { + "".to_string() +} + +fn default_request_path() -> String { + "".to_string() +} + +fn default_request_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_response_status_code() -> i64 { + 0 +} + +fn default_response_body() -> String { + "".to_string() +} + +fn default_response_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_errors() -> String { + "".to_string() +} + +fn default_duration() -> f64 { + 0.0 +} + impl Execution { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution_list.rs b/src/models/execution_list.rs index 85fa76f..d30bc6c 100644 --- a/src/models/execution_list.rs +++ b/src/models/execution_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ExecutionList { /// Total number of executions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of executions. #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_executions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ExecutionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/file.rs b/src/models/file.rs index 1310f94..1f95426 100644 --- a/src/models/file.rs +++ b/src/models/file.rs @@ -8,58 +8,138 @@ use serde::{Deserialize, Serialize}; pub struct File { /// File ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket ID. #[serde(rename = "bucketId")] + #[serde(default = "default_bucket_id")] pub bucket_id: String, /// File creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// File update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// File permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// File name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Virtual folder containing the file, with a trailing slash. Empty for the /// bucket root. #[serde(rename = "folder")] + #[serde(default = "default_folder")] pub folder: String, /// Full virtual path of the file: the folder followed by the file name. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// File MD5 signature. #[serde(rename = "signature")] + #[serde(default = "default_signature")] pub signature: String, /// File mime type. #[serde(rename = "mimeType")] + #[serde(default = "default_mime_type")] pub mime_type: String, /// File original size in bytes. #[serde(rename = "sizeOriginal")] + #[serde(default = "default_size_original")] pub size_original: i64, /// File actual stored size in bytes after compression and/or encryption. #[serde(rename = "sizeActual")] + #[serde(default = "default_size_actual")] pub size_actual: i64, /// Total number of chunks available #[serde(rename = "chunksTotal")] + #[serde(default = "default_chunks_total")] pub chunks_total: i64, /// Total number of chunks uploaded #[serde(rename = "chunksUploaded")] + #[serde(default = "default_chunks_uploaded")] pub chunks_uploaded: i64, /// Whether file contents are encrypted at rest. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Compression algorithm used for the file. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_bucket_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_folder() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_signature() -> String { + "".to_string() +} + +fn default_mime_type() -> String { + "".to_string() +} + +fn default_size_original() -> i64 { + 0 +} + +fn default_size_actual() -> i64 { + 0 +} + +fn default_chunks_total() -> i64 { + 0 +} + +fn default_chunks_uploaded() -> i64 { + 0 +} + +fn default_encryption() -> bool { + false +} + +fn default_compression() -> String { + "none".to_string() +} + impl File { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/file_list.rs b/src/models/file_list.rs index bc9f598..06a0bec 100644 --- a/src/models/file_list.rs +++ b/src/models/file_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FileList { /// Total number of files that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of files. #[serde(rename = "files")] + #[serde(default = "default_files")] pub files: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_files() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FileList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/framework.rs b/src/models/framework.rs index fbc7a82..2f04803 100644 --- a/src/models/framework.rs +++ b/src/models/framework.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct Framework { /// Framework key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Framework Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Default runtime version. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// List of supported runtime versions. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, /// List of supported adapters. #[serde(rename = "adapters")] + #[serde(default = "default_adapters")] pub adapters: Vec, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_adapters() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Framework { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_adapter.rs b/src/models/framework_adapter.rs index 5ffe882..d945c32 100644 --- a/src/models/framework_adapter.rs +++ b/src/models/framework_adapter.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkAdapter { /// Adapter key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Default command to download dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// Default command to build site into output directory. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Default output directory of build. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Name of fallback file to use instead of 404 page. If null, Appwrite 404 /// page will be displayed. @@ -25,6 +29,22 @@ pub struct FrameworkAdapter { pub fallback_file: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + impl FrameworkAdapter { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_list.rs b/src/models/framework_list.rs index 9d8570f..fd7e484 100644 --- a/src/models/framework_list.rs +++ b/src/models/framework_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkList { /// Total number of frameworks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of frameworks. #[serde(rename = "frameworks")] + #[serde(default = "default_frameworks")] pub frameworks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_frameworks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FrameworkList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/function.rs b/src/models/function.rs index 06374cd..1ec588b 100644 --- a/src/models/function.rs +++ b/src/models/function.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct Function { /// Function ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Function creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Function update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution permissions. #[serde(rename = "execute")] + #[serde(default = "default_execute")] pub execute: Vec, /// Function name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Function enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the function deployed with the latest configuration? This is set to /// false if you've changed an environment variables, entrypoint, commands, or /// other settings that needs redeploy to be applied. When the value is false, /// redeploy the function to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, executions will exclude logs and errors, and will be /// slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Function execution and build runtime. #[serde(rename = "runtime")] + #[serde(default = "default_runtime")] pub runtime: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Function's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Function's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Function variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Function trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Function execution schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Minutes between scheduled executions. 0 when the function has no interval. #[serde(rename = "interval")] @@ -75,49 +94,190 @@ pub struct Function { pub interval: Option, /// Function execution timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The entrypoint file used to execute the deployment. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The build command used to build the deployment. #[serde(rename = "commands")] + #[serde(default = "default_commands")] pub commands: String, /// Version of Open Runtimes used for the function. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Function VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to function in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_execute() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_runtime() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_schedule() -> String { + "".to_string() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_commands() -> String { + "".to_string() +} + +fn default_version() -> String { + "v5".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + impl Function { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/function_list.rs b/src/models/function_list.rs index ff9a37d..ee30315 100644 --- a/src/models/function_list.rs +++ b/src/models/function_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FunctionList { /// Total number of functions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of functions. #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_functions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FunctionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/headers.rs b/src/models/headers.rs index 87a2b64..2aed2bc 100644 --- a/src/models/headers.rs +++ b/src/models/headers.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Headers { /// Header name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Header value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + impl Headers { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/identity.rs b/src/models/identity.rs index aca8541..bc00cf8 100644 --- a/src/models/identity.rs +++ b/src/models/identity.rs @@ -8,39 +8,93 @@ use serde::{Deserialize, Serialize}; pub struct Identity { /// Identity ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Identity creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Identity update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Identity Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// ID of the User in the Identity Provider. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Email of the User in the Identity Provider. #[serde(rename = "providerEmail")] + #[serde(default = "default_provider_email")] pub provider_email: String, /// Identity Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Identity Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// Identity Provider ID token (JWT) from the most recent native sign-in. Empty /// for identities created through the browser OAuth2 flow. #[serde(rename = "providerIdToken")] - #[serde(skip_serializing_if = "Option::is_none")] - pub provider_id_token: Option, + #[serde(default = "default_provider_id_token")] + pub provider_id_token: String, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_email() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_provider_id_token() -> String { + "".to_string() } impl Identity { @@ -94,15 +148,9 @@ impl Identity { &self.provider_refresh_token } - /// Set provider_id_token - pub fn set_provider_id_token(mut self, provider_id_token: String) -> Self { - self.provider_id_token = Some(provider_id_token); - self - } - /// Get provider_id_token - pub fn provider_id_token(&self) -> Option<&String> { - self.provider_id_token.as_ref() + pub fn provider_id_token(&self) -> &String { + &self.provider_id_token } } @@ -123,6 +171,7 @@ mod tests { let _ = _model.provider_access_token(); let _ = _model.provider_access_token_expiry(); let _ = _model.provider_refresh_token(); + let _ = _model.provider_id_token(); } #[test] diff --git a/src/models/identity_list.rs b/src/models/identity_list.rs index b8cca8a..951990d 100644 --- a/src/models/identity_list.rs +++ b/src/models/identity_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IdentityList { /// Total number of identities that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of identities. #[serde(rename = "identities")] + #[serde(default = "default_identities")] pub identities: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_identities() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IdentityList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/index.rs b/src/models/index.rs index d18b386..b3865e8 100644 --- a/src/models/index.rs +++ b/src/models/index.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Index { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -28,12 +33,15 @@ pub struct Index { /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Index attributes length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +49,38 @@ pub struct Index { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Index { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/index_list.rs b/src/models/index_list.rs index 48eec9e..39499dc 100644 --- a/src/models/index_list.rs +++ b/src/models/index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/insight.rs b/src/models/insight.rs index 937d6f7..e514aca 100644 --- a/src/models/insight.rs +++ b/src/models/insight.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct Insight { /// Insight ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Insight creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Insight update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Parent report ID. Insights always belong to a report. #[serde(rename = "reportId")] + #[serde(default = "default_report_id")] pub report_id: String, /// Insight type. One of databaseIndex (legacy), tablesDBIndex, /// documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, @@ -25,36 +29,46 @@ pub struct Insight { /// (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or /// vectorsDB.createIndex). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Insight severity. One of info, warning, critical. #[serde(rename = "severity")] + #[serde(default = "default_severity")] pub severity: String, /// Insight status. One of active, dismissed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Type of the resource the insight is about. Plural noun, e.g. databases, /// sites, functions. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of the resource the insight is about. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Plural noun for the parent resource that contains the insight's resource, /// e.g. an insight about a column index on a table → resourceType=indexes, /// parentResourceType=tables. Empty when the resource has no parent. #[serde(rename = "parentResourceType")] + #[serde(default = "default_parent_resource_type")] pub parent_resource_type: String, /// ID of the parent resource. Empty when the resource has no parent. #[serde(rename = "parentResourceId")] + #[serde(default = "default_parent_resource_id")] pub parent_resource_id: String, /// Insight title. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Short markdown summary describing the insight. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// List of call-to-action buttons attached to this insight. #[serde(rename = "ctas")] + #[serde(default = "default_ctas")] pub ctas: Vec, /// Time the insight was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -71,6 +85,62 @@ pub struct Insight { pub dismissed_by: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_report_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_severity() -> String { + "info".to_string() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_parent_resource_type() -> String { + "".to_string() +} + +fn default_parent_resource_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_ctas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Insight { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/insight_cta.rs b/src/models/insight_cta.rs index 6a3b719..d96fa8a 100644 --- a/src/models/insight_cta.rs +++ b/src/models/insight_cta.rs @@ -8,24 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct InsightCTA { /// Human-readable label for the CTA, used in UI. #[serde(rename = "label")] + #[serde(default = "default_label")] pub label: String, /// Public API service (SDK namespace) the client should invoke. Must match the /// engine that owns the resource — for index suggestions: databases /// (legacy), tablesDB, documentsDB, or vectorsDB. #[serde(rename = "service")] + #[serde(default = "default_service")] pub service: String, /// Public API method on the chosen service the client should invoke when this /// CTA is triggered. #[serde(rename = "method")] + #[serde(default = "default_method")] pub method: String, /// Parameter map the client should pass to the service method when this CTA is /// triggered. Keys match the target API's parameter names (e.g. /// databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes /// for the legacy Databases API). #[serde(rename = "params")] + #[serde(default = "default_params")] pub params: serde_json::Value, } +fn default_label() -> String { + "".to_string() +} + +fn default_service() -> String { + "".to_string() +} + +fn default_method() -> String { + "".to_string() +} + +fn default_params() -> serde_json::Value { + serde_json::json!({}) +} + impl InsightCTA { /// Get label pub fn label(&self) -> &String { diff --git a/src/models/insight_list.rs b/src/models/insight_list.rs index 54b229c..e5b6d1a 100644 --- a/src/models/insight_list.rs +++ b/src/models/insight_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct InsightList { /// Total number of insights that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of insights. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl InsightList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/jwt.rs b/src/models/jwt.rs index 8482207..535cf61 100644 --- a/src/models/jwt.rs +++ b/src/models/jwt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Jwt { /// JWT encoded string. #[serde(rename = "jwt")] + #[serde(default = "default_jwt")] pub jwt: String, } +fn default_jwt() -> String { + "".to_string() +} + impl Jwt { /// Get jwt pub fn jwt(&self) -> &String { diff --git a/src/models/key.rs b/src/models/key.rs index 109b8d5..06b83c7 100644 --- a/src/models/key.rs +++ b/src/models/key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct Key { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Key { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/key_list.rs b/src/models/key_list.rs index 0cad143..767cf5e 100644 --- a/src/models/key_list.rs +++ b/src/models/key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct KeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl KeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/language.rs b/src/models/language.rs index bef7ec4..fd3d530 100644 --- a/src/models/language.rs +++ b/src/models/language.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Language { /// Language name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Language two-character ISO 639-1 codes. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Language native name. #[serde(rename = "nativeName")] + #[serde(default = "default_native_name")] pub native_name: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + +fn default_native_name() -> String { + "".to_string() +} + impl Language { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/language_list.rs b/src/models/language_list.rs index 42d79d9..9993952 100644 --- a/src/models/language_list.rs +++ b/src/models/language_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LanguageList { /// Total number of languages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of languages. #[serde(rename = "languages")] + #[serde(default = "default_languages")] pub languages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_languages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LanguageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/locale.rs b/src/models/locale.rs index 08b7f02..ecd0d0d 100644 --- a/src/models/locale.rs +++ b/src/models/locale.rs @@ -8,28 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Locale { /// User IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) /// two-character format #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. This field support localization. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. A two character continent code "AF" for Africa, "AN" for /// Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" /// for Oceania, and "SA" for South America. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// Continent name. This field support localization. #[serde(rename = "continent")] + #[serde(default = "default_continent")] pub continent: String, /// True if country is part of the European Union. #[serde(rename = "eu")] + #[serde(default = "default_eu")] pub eu: bool, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// City #[serde(rename = "city")] @@ -77,6 +84,34 @@ pub struct Locale { pub connection_organization: Option, } +fn default_ip() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_continent() -> String { + "".to_string() +} + +fn default_eu() -> bool { + false +} + +fn default_currency() -> String { + "".to_string() +} + impl Locale { /// Get ip pub fn ip(&self) -> &String { diff --git a/src/models/locale_code.rs b/src/models/locale_code.rs index 389f8a2..84b8601 100644 --- a/src/models/locale_code.rs +++ b/src/models/locale_code.rs @@ -9,12 +9,22 @@ pub struct LocaleCode { /// Locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Locale name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + impl LocaleCode { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/locale_code_list.rs b/src/models/locale_code_list.rs index e8e2ebb..8314d75 100644 --- a/src/models/locale_code_list.rs +++ b/src/models/locale_code_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LocaleCodeList { /// Total number of localeCodes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of localeCodes. #[serde(rename = "localeCodes")] + #[serde(default = "default_locale_codes")] pub locale_codes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_locale_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LocaleCodeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/log.rs b/src/models/log.rs deleted file mode 100644 index c62709d..0000000 --- a/src/models/log.rs +++ /dev/null @@ -1,235 +0,0 @@ -//! Log model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Log -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct Log { - /// Event name. - #[serde(rename = "event")] - pub event: String, - /// User ID of the actor recorded for this log. During impersonation, this is - /// the original impersonator, not the impersonated target user. - #[serde(rename = "userId")] - pub user_id: String, - /// User email of the actor recorded for this log. During impersonation, this - /// is the original impersonator. - #[serde(rename = "userEmail")] - pub user_email: String, - /// User name of the actor recorded for this log. During impersonation, this is - /// the original impersonator. - #[serde(rename = "userName")] - pub user_name: String, - /// API mode when event triggered. - #[serde(rename = "mode")] - pub mode: String, - /// User type who triggered the audit log. Possible values: user, admin, guest, - /// hidden, keyProject, keyAccount, keyOrganization. - #[serde(rename = "userType")] - pub user_type: String, - /// IP session in use when the session was created. - #[serde(rename = "ip")] - pub ip: String, - /// Log creation date in ISO 8601 format. - #[serde(rename = "time")] - pub time: String, - /// Operating system code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - #[serde(rename = "osCode")] - pub os_code: String, - /// Operating system name. - #[serde(rename = "osName")] - pub os_name: String, - /// Operating system version. - #[serde(rename = "osVersion")] - pub os_version: String, - /// Client type. - #[serde(rename = "clientType")] - pub client_type: String, - /// Client code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - #[serde(rename = "clientCode")] - pub client_code: String, - /// Client name. - #[serde(rename = "clientName")] - pub client_name: String, - /// Client version. - #[serde(rename = "clientVersion")] - pub client_version: String, - /// Client engine name. - #[serde(rename = "clientEngine")] - pub client_engine: String, - /// Client engine name. - #[serde(rename = "clientEngineVersion")] - pub client_engine_version: String, - /// Device name. - #[serde(rename = "deviceName")] - pub device_name: String, - /// Device brand name. - #[serde(rename = "deviceBrand")] - pub device_brand: String, - /// Device model name. - #[serde(rename = "deviceModel")] - pub device_model: String, - /// Country two-character ISO 3166-1 alpha code. - #[serde(rename = "countryCode")] - pub country_code: String, - /// Country name. - #[serde(rename = "countryName")] - pub country_name: String, -} - -impl Log { - /// Get event - pub fn event(&self) -> &String { - &self.event - } - - /// Get user_id - pub fn user_id(&self) -> &String { - &self.user_id - } - - /// Get user_email - pub fn user_email(&self) -> &String { - &self.user_email - } - - /// Get user_name - pub fn user_name(&self) -> &String { - &self.user_name - } - - /// Get mode - pub fn mode(&self) -> &String { - &self.mode - } - - /// Get user_type - pub fn user_type(&self) -> &String { - &self.user_type - } - - /// Get ip - pub fn ip(&self) -> &String { - &self.ip - } - - /// Get time - pub fn time(&self) -> &String { - &self.time - } - - /// Get os_code - pub fn os_code(&self) -> &String { - &self.os_code - } - - /// Get os_name - pub fn os_name(&self) -> &String { - &self.os_name - } - - /// Get os_version - pub fn os_version(&self) -> &String { - &self.os_version - } - - /// Get client_type - pub fn client_type(&self) -> &String { - &self.client_type - } - - /// Get client_code - pub fn client_code(&self) -> &String { - &self.client_code - } - - /// Get client_name - pub fn client_name(&self) -> &String { - &self.client_name - } - - /// Get client_version - pub fn client_version(&self) -> &String { - &self.client_version - } - - /// Get client_engine - pub fn client_engine(&self) -> &String { - &self.client_engine - } - - /// Get client_engine_version - pub fn client_engine_version(&self) -> &String { - &self.client_engine_version - } - - /// Get device_name - pub fn device_name(&self) -> &String { - &self.device_name - } - - /// Get device_brand - pub fn device_brand(&self) -> &String { - &self.device_brand - } - - /// Get device_model - pub fn device_model(&self) -> &String { - &self.device_model - } - - /// Get country_code - pub fn country_code(&self) -> &String { - &self.country_code - } - - /// Get country_name - pub fn country_name(&self) -> &String { - &self.country_name - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_creation() { - let _model = ::default(); - let _ = _model.event(); - let _ = _model.user_id(); - let _ = _model.user_email(); - let _ = _model.user_name(); - let _ = _model.mode(); - let _ = _model.user_type(); - let _ = _model.ip(); - let _ = _model.time(); - let _ = _model.os_code(); - let _ = _model.os_name(); - let _ = _model.os_version(); - let _ = _model.client_type(); - let _ = _model.client_code(); - let _ = _model.client_name(); - let _ = _model.client_version(); - let _ = _model.client_engine(); - let _ = _model.client_engine_version(); - let _ = _model.device_name(); - let _ = _model.device_brand(); - let _ = _model.device_model(); - let _ = _model.country_code(); - let _ = _model.country_name(); - } - - #[test] - fn test_log_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/log_list.rs b/src/models/log_list.rs deleted file mode 100644 index 8215ec2..0000000 --- a/src/models/log_list.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! LogList model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Logs List -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct LogList { - /// Total number of logs that matched your query. - #[serde(rename = "total")] - pub total: i64, - /// List of logs. - #[serde(rename = "logs")] - pub logs: Vec, -} - -impl LogList { - /// Get total - pub fn total(&self) -> &i64 { - &self.total - } - - /// Get logs - pub fn logs(&self) -> &Vec { - &self.logs - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_list_creation() { - let _model = ::default(); - let _ = _model.total(); - let _ = _model.logs(); - } - - #[test] - fn test_log_list_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/membership.rs b/src/models/membership.rs index da724ca..bc0954e 100644 --- a/src/models/membership.rs +++ b/src/models/membership.rs @@ -8,59 +8,134 @@ use serde::{Deserialize, Serialize}; pub struct Membership { /// Membership ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Membership creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Membership update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User name. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// User email address. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: String, /// User phone number. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Team name. #[serde(rename = "teamName")] + #[serde(default = "default_team_name")] pub team_name: String, /// Date, the user has been invited to join the team in ISO 8601 format. #[serde(rename = "invited")] + #[serde(default = "default_invited")] pub invited: String, /// Date, the user has accepted the invitation to join the team in ISO 8601 /// format. #[serde(rename = "joined")] + #[serde(default = "default_joined")] pub joined: String, /// User confirmation status, true if the user has joined the team or false /// otherwise. #[serde(rename = "confirm")] + #[serde(default = "default_confirm")] pub confirm: bool, /// Multi factor authentication status, true if the user has MFA enabled or /// false otherwise. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// Most recent access date in ISO 8601 format. Show this attribute by toggling /// membership privacy in the Console. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: String, /// User list of roles #[serde(rename = "roles")] + #[serde(default = "default_roles")] pub roles: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_user_email() -> String { + "".to_string() +} + +fn default_user_phone() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_team_name() -> String { + "".to_string() +} + +fn default_invited() -> String { + "".to_string() +} + +fn default_joined() -> String { + "".to_string() +} + +fn default_confirm() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> String { + "".to_string() +} + +fn default_roles() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Membership { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/membership_list.rs b/src/models/membership_list.rs index 628a569..a5c2d03 100644 --- a/src/models/membership_list.rs +++ b/src/models/membership_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MembershipList { /// Total number of memberships that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of memberships. #[serde(rename = "memberships")] + #[serde(default = "default_memberships")] pub memberships: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_memberships() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MembershipList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/message.rs b/src/models/message.rs index 554149b..29880eb 100644 --- a/src/models/message.rs +++ b/src/models/message.rs @@ -8,24 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Message { /// Message ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Message creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Message update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Message provider type. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// Topic IDs set as recipients. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, /// User IDs set as recipients. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, /// Target IDs set as recipients. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// The scheduled time for message. #[serde(rename = "scheduledAt")] @@ -41,15 +48,58 @@ pub struct Message { pub delivery_errors: Option>, /// Number of recipients the message was delivered to. #[serde(rename = "deliveredTotal")] + #[serde(default = "default_delivered_total")] pub delivered_total: i64, /// Data of the message. #[serde(rename = "data")] + #[serde(default = "default_data")] pub data: serde_json::Value, /// Status of delivery. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::MessageStatus, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_delivered_total() -> i64 { + 0 +} + +fn default_data() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_status() -> crate::enums::MessageStatus { + serde_json::from_value(serde_json::json!("draft")).unwrap() +} + impl Message { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/message_list.rs b/src/models/message_list.rs index de470cb..628ae06 100644 --- a/src/models/message_list.rs +++ b/src/models/message_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MessageList { /// Total number of messages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of messages. #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_messages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MessageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mfa_challenge.rs b/src/models/mfa_challenge.rs index cee280b..ce8a91a 100644 --- a/src/models/mfa_challenge.rs +++ b/src/models/mfa_challenge.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallenge { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl MfaChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_challenge_secret.rs b/src/models/mfa_challenge_secret.rs index 42a9c6e..e21b3ae 100644 --- a/src/models/mfa_challenge_secret.rs +++ b/src/models/mfa_challenge_secret.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallengeSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Challenge code to be delivered to the end user through a custom channel. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl MfaChallengeSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_factors.rs b/src/models/mfa_factors.rs index 14b1ebf..6415f45 100644 --- a/src/models/mfa_factors.rs +++ b/src/models/mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaFactors { /// Can TOTP be used for MFA challenge for this account. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Can phone (SMS) be used for MFA challenge for this account. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Can email be used for MFA challenge for this account. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Can recovery code be used for MFA challenge for this account. #[serde(rename = "recoveryCode")] + #[serde(default = "default_recovery_code")] pub recovery_code: bool, /// Can custom factor be used for MFA challenge for this account. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_totp() -> bool { + false +} + +fn default_phone() -> bool { + false +} + +fn default_email() -> bool { + false +} + +fn default_recovery_code() -> bool { + false +} + +fn default_custom() -> bool { + false +} + impl MfaFactors { /// Get totp pub fn totp(&self) -> &bool { diff --git a/src/models/mfa_recovery_codes.rs b/src/models/mfa_recovery_codes.rs index 44f77a3..c9089ef 100644 --- a/src/models/mfa_recovery_codes.rs +++ b/src/models/mfa_recovery_codes.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct MfaRecoveryCodes { /// Recovery codes. #[serde(rename = "recoveryCodes")] + #[serde(default = "default_recovery_codes")] pub recovery_codes: Vec, } +fn default_recovery_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MfaRecoveryCodes { /// Get recovery_codes pub fn recovery_codes(&self) -> &Vec { diff --git a/src/models/mfa_type.rs b/src/models/mfa_type.rs index 7809d95..69e7a79 100644 --- a/src/models/mfa_type.rs +++ b/src/models/mfa_type.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MfaType { /// Secret token used for TOTP factor. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// URI for authenticator apps. #[serde(rename = "uri")] + #[serde(default = "default_uri")] pub uri: String, } +fn default_secret() -> String { + "".to_string() +} + +fn default_uri() -> String { + "".to_string() +} + impl MfaType { /// Get secret pub fn secret(&self) -> &String { diff --git a/src/models/mock_number.rs b/src/models/mock_number.rs index 1d8ea85..0a7244c 100644 --- a/src/models/mock_number.rs +++ b/src/models/mock_number.rs @@ -9,18 +9,38 @@ pub struct MockNumber { /// Mock phone number for testing phone authentication. Useful for testing /// phone authentication without sending an SMS. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: String, /// Mock OTP for the number. #[serde(rename = "otp")] + #[serde(default = "default_otp")] pub otp: String, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_number() -> String { + "".to_string() +} + +fn default_otp() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl MockNumber { /// Get number pub fn number(&self) -> &String { diff --git a/src/models/mock_number_list.rs b/src/models/mock_number_list.rs index b4d7f7f..44de93f 100644 --- a/src/models/mock_number_list.rs +++ b/src/models/mock_number_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MockNumberList { /// Total number of mockNumbers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of mockNumbers. #[serde(rename = "mockNumbers")] + #[serde(default = "default_mock_numbers")] pub mock_numbers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_mock_numbers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MockNumberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mod.rs b/src/models/mod.rs index 8c4e935..1eb0426 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -22,8 +22,6 @@ pub mod session_list; pub use session_list::SessionList; pub mod identity_list; pub use identity_list::IdentityList; -pub mod log_list; -pub use log_list::LogList; pub mod file_list; pub use file_list::FileList; pub mod bucket_list; @@ -196,8 +194,6 @@ pub mod document; pub use document::Document; pub mod presence; pub use presence::Presence; -pub mod log; -pub use log::Log; pub mod user; pub use user::User; pub mod algo_md5; @@ -268,8 +264,6 @@ pub mod key; pub use key::Key; pub mod ephemeral_key; pub use ephemeral_key::EphemeralKey; -pub mod dev_key; -pub use dev_key::DevKey; pub mod mock_number; pub use mock_number::MockNumber; pub mod o_auth2_github; @@ -396,6 +390,14 @@ pub mod policy_mfa_factors; pub use policy_mfa_factors::PolicyMfaFactors; pub mod policy_passkey; pub use policy_passkey::PolicyPasskey; +pub mod policy_deny_aliased_email; +pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; +pub mod policy_deny_disposable_email; +pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; +pub mod policy_deny_free_email; +pub use policy_deny_free_email::PolicyDenyFreeEmail; +pub mod policy_deny_corporate_email; +pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod platform_web; pub use platform_web::PlatformWeb; pub mod platform_apple; @@ -534,14 +536,6 @@ pub mod dedicated_database_pitr_windows; pub use dedicated_database_pitr_windows::DedicatedDatabasePITRWindows; pub mod backup_policy; pub use backup_policy::BackupPolicy; -pub mod policy_deny_aliased_email; -pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; -pub mod policy_deny_disposable_email; -pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; -pub mod policy_deny_free_email; -pub use policy_deny_free_email::PolicyDenyFreeEmail; -pub mod policy_deny_corporate_email; -pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod dedicated_database_pooler; pub use dedicated_database_pooler::DedicatedDatabasePooler; pub mod postgres_extension; @@ -556,8 +550,6 @@ pub mod dedicated_database_specification; pub use dedicated_database_specification::DedicatedDatabaseSpecification; pub mod dedicated_database_specification_list; pub use dedicated_database_specification_list::DedicatedDatabaseSpecificationList; -pub mod dedicated_database_specification_pricing; -pub use dedicated_database_specification_pricing::DedicatedDatabaseSpecificationPricing; pub mod database_status_connections; pub use database_status_connections::DatabaseStatusConnections; pub mod database_status_replica; @@ -669,7 +661,6 @@ impl Model for ColumnIndexList {} impl Model for UserList {} impl Model for SessionList {} impl Model for IdentityList {} -impl Model for LogList {} impl Model for FileList {} impl Model for BucketList {} impl Model for ResourceTokenList {} @@ -756,7 +747,6 @@ impl Model for ColumnIndex {} impl Model for Row {} impl Model for Document {} impl Model for Presence {} -impl Model for Log {} impl Model for User {} impl Model for AlgoMd5 {} impl Model for AlgoSha {} @@ -792,7 +782,6 @@ impl Model for ProjectProtocol {} impl Model for Webhook {} impl Model for Key {} impl Model for EphemeralKey {} -impl Model for DevKey {} impl Model for MockNumber {} impl Model for OAuth2Github {} impl Model for OAuth2Discord {} @@ -856,6 +845,10 @@ impl Model for PolicyUserLimit {} impl Model for PolicyMembershipPrivacy {} impl Model for PolicyMfaFactors {} impl Model for PolicyPasskey {} +impl Model for PolicyDenyAliasedEmail {} +impl Model for PolicyDenyDisposableEmail {} +impl Model for PolicyDenyFreeEmail {} +impl Model for PolicyDenyCorporateEmail {} impl Model for PlatformWeb {} impl Model for PlatformApple {} impl Model for PlatformAndroid {} @@ -925,10 +918,6 @@ impl Model for ProxyInvalidation {} impl Model for Organization {} impl Model for DedicatedDatabasePITRWindows {} impl Model for BackupPolicy {} -impl Model for PolicyDenyAliasedEmail {} -impl Model for PolicyDenyDisposableEmail {} -impl Model for PolicyDenyFreeEmail {} -impl Model for PolicyDenyCorporateEmail {} impl Model for DedicatedDatabasePooler {} impl Model for PostgresExtension {} impl Model for Program {} @@ -936,7 +925,6 @@ impl Model for BackupRestoration {} impl Model for DedicatedDatabaseRestorationList {} impl Model for DedicatedDatabaseSpecification {} impl Model for DedicatedDatabaseSpecificationList {} -impl Model for DedicatedDatabaseSpecificationPricing {} impl Model for DatabaseStatusConnections {} impl Model for DatabaseStatusReplica {} impl Model for DatabaseStatusVolume {} diff --git a/src/models/o_auth2_amazon.rs b/src/models/o_auth2_amazon.rs index c2359b9..6e79642 100644 --- a/src/models/o_auth2_amazon.rs +++ b/src/models/o_auth2_amazon.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Amazon { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Amazon OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Amazon OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Amazon { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_apple.rs b/src/models/o_auth2_apple.rs index 5022915..3b357f7 100644 --- a/src/models/o_auth2_apple.rs +++ b/src/models/o_auth2_apple.rs @@ -8,34 +8,72 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Apple { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Apple OAuth2 service ID. #[serde(rename = "serviceId")] + #[serde(default = "default_service_id")] pub service_id: String, /// Apple OAuth2 key ID. #[serde(rename = "keyId")] + #[serde(default = "default_key_id")] pub key_id: String, /// Apple OAuth2 team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Apple OAuth2 .p8 private key file contents. The secret key wrapped by the /// PEM markers is 200 characters long. #[serde(rename = "p8File")] + #[serde(default = "default_p8_file")] pub p8_file: String, /// Native Sign in with Apple is active and can be used to create sessions from /// an ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// App bundle IDs accepted as ID token audiences for native Sign in with /// Apple, next to the Services ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_service_id() -> String { + "".to_string() +} + +fn default_key_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_p8_file() -> String { + "".to_string() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Apple { @@ -69,26 +107,14 @@ impl OAuth2Apple { &self.p8_file } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -105,6 +131,8 @@ mod tests { let _ = _model.key_id(); let _ = _model.team_id(); let _ = _model.p8_file(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_appwrite.rs b/src/models/o_auth2_appwrite.rs index 4ca0449..54ce0c8 100644 --- a/src/models/o_auth2_appwrite.rs +++ b/src/models/o_auth2_appwrite.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Appwrite { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Appwrite OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Appwrite OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Appwrite { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_auth0.rs b/src/models/o_auth2_auth0.rs index 12a3426..c974616 100644 --- a/src/models/o_auth2_auth0.rs +++ b/src/models/o_auth2_auth0.rs @@ -8,25 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Auth0 { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Auth0 OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Auth0 OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Auth0 OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Auth0 OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Auth0 { /// Get id pub fn id(&self) -> &String { @@ -48,15 +77,9 @@ impl OAuth2Auth0 { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get endpoint @@ -76,6 +99,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.endpoint(); } diff --git a/src/models/o_auth2_authentik.rs b/src/models/o_auth2_authentik.rs index da60963..8a4735b 100644 --- a/src/models/o_auth2_authentik.rs +++ b/src/models/o_auth2_authentik.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Authentik { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Authentik OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Authentik OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Authentik OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Authentik { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_autodesk.rs b/src/models/o_auth2_autodesk.rs index a487d8a..2f30585 100644 --- a/src/models/o_auth2_autodesk.rs +++ b/src/models/o_auth2_autodesk.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Autodesk { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Autodesk OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Autodesk OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Autodesk { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitbucket.rs b/src/models/o_auth2_bitbucket.rs index cfe595b..1694254 100644 --- a/src/models/o_auth2_bitbucket.rs +++ b/src/models/o_auth2_bitbucket.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitbucket { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitbucket OAuth2 key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Bitbucket OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + impl OAuth2Bitbucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitly.rs b/src/models/o_auth2_bitly.rs index 15a0774..1f0d383 100644 --- a/src/models/o_auth2_bitly.rs +++ b/src/models/o_auth2_bitly.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitly { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitly OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Bitly OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Bitly { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_box.rs b/src/models/o_auth2_box.rs index 83959c8..c2fefe6 100644 --- a/src/models/o_auth2_box.rs +++ b/src/models/o_auth2_box.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Box { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Box OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Box OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Box { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_cloudflare.rs b/src/models/o_auth2_cloudflare.rs index 3f6703f..6c977c2 100644 --- a/src/models/o_auth2_cloudflare.rs +++ b/src/models/o_auth2_cloudflare.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Cloudflare { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Cloudflare OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Cloudflare OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Cloudflare { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dailymotion.rs b/src/models/o_auth2_dailymotion.rs index b94e6bc..795a455 100644 --- a/src/models/o_auth2_dailymotion.rs +++ b/src/models/o_auth2_dailymotion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dailymotion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dailymotion OAuth2 API key. #[serde(rename = "apiKey")] + #[serde(default = "default_api_key")] pub api_key: String, /// Dailymotion OAuth2 API secret. #[serde(rename = "apiSecret")] + #[serde(default = "default_api_secret")] pub api_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_api_key() -> String { + "".to_string() +} + +fn default_api_secret() -> String { + "".to_string() +} + impl OAuth2Dailymotion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_discord.rs b/src/models/o_auth2_discord.rs index 91a601b..9c0c58d 100644 --- a/src/models/o_auth2_discord.rs +++ b/src/models/o_auth2_discord.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Discord { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Discord OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Discord OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Discord OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Discord { @@ -45,15 +69,9 @@ impl OAuth2Discord { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_disqus.rs b/src/models/o_auth2_disqus.rs index 467e840..957c4f6 100644 --- a/src/models/o_auth2_disqus.rs +++ b/src/models/o_auth2_disqus.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Disqus { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Disqus OAuth2 public key. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: String, /// Disqus OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_public_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Disqus { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dropbox.rs b/src/models/o_auth2_dropbox.rs index d566903..9160dbd 100644 --- a/src/models/o_auth2_dropbox.rs +++ b/src/models/o_auth2_dropbox.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dropbox { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dropbox OAuth2 app key. #[serde(rename = "appKey")] + #[serde(default = "default_app_key")] pub app_key: String, /// Dropbox OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_key() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Dropbox { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_etsy.rs b/src/models/o_auth2_etsy.rs index cf6bab9..a0158a0 100644 --- a/src/models/o_auth2_etsy.rs +++ b/src/models/o_auth2_etsy.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Etsy { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Etsy OAuth2 keystring. #[serde(rename = "keyString")] + #[serde(default = "default_key_string")] pub key_string: String, /// Etsy OAuth2 shared secret. #[serde(rename = "sharedSecret")] + #[serde(default = "default_shared_secret")] pub shared_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key_string() -> String { + "".to_string() +} + +fn default_shared_secret() -> String { + "".to_string() +} + impl OAuth2Etsy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_facebook.rs b/src/models/o_auth2_facebook.rs index c8c3bd9..7cabbef 100644 --- a/src/models/o_auth2_facebook.rs +++ b/src/models/o_auth2_facebook.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Facebook { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Facebook OAuth2 app ID. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Facebook OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Facebook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_figma.rs b/src/models/o_auth2_figma.rs index 0ef3e3b..99c241c 100644 --- a/src/models/o_auth2_figma.rs +++ b/src/models/o_auth2_figma.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Figma { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Figma OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Figma OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Figma { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_fusion_auth.rs b/src/models/o_auth2_fusion_auth.rs index 2222752..a9a7122 100644 --- a/src/models/o_auth2_fusion_auth.rs +++ b/src/models/o_auth2_fusion_auth.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2FusionAuth { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// FusionAuth OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// FusionAuth OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// FusionAuth OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2FusionAuth { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_github.rs b/src/models/o_auth2_github.rs index 1be7953..684abde 100644 --- a/src/models/o_auth2_github.rs +++ b/src/models/o_auth2_github.rs @@ -8,21 +8,45 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Github { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App /// ID and client ID are available. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// GitHub OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// GitHub OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Github { @@ -46,15 +70,9 @@ impl OAuth2Github { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -69,6 +87,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_gitlab.rs b/src/models/o_auth2_gitlab.rs index 8444d1b..fa76ce7 100644 --- a/src/models/o_auth2_gitlab.rs +++ b/src/models/o_auth2_gitlab.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Gitlab { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitLab OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// GitLab OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted /// instances. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Gitlab { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_google.rs b/src/models/o_auth2_google.rs index ece34e2..e9261a9 100644 --- a/src/models/o_auth2_google.rs +++ b/src/models/o_auth2_google.rs @@ -8,30 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Google { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Google OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Google OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Google OAuth2 prompt values. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: Vec, /// Native Google sign-in is active and can be used to create sessions from an /// ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// Additional OAuth2 client IDs accepted as ID token audiences for native /// sign-in, next to the client ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!(["consent"])).unwrap() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Google { @@ -60,26 +93,14 @@ impl OAuth2Google { &self.prompt } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -95,6 +116,8 @@ mod tests { let _ = _model.client_id(); let _ = _model.client_secret(); let _ = _model.prompt(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_hugging_face.rs b/src/models/o_auth2_hugging_face.rs index 6259543..43b9831 100644 --- a/src/models/o_auth2_hugging_face.rs +++ b/src/models/o_auth2_hugging_face.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2HuggingFace { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Hugging Face OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Hugging Face OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2HuggingFace { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_keycloak.rs b/src/models/o_auth2_keycloak.rs index 1586924..b5fd439 100644 --- a/src/models/o_auth2_keycloak.rs +++ b/src/models/o_auth2_keycloak.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Keycloak { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Keycloak OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Keycloak OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Keycloak OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, /// Keycloak OAuth2 realm name. #[serde(rename = "realmName")] + #[serde(default = "default_realm_name")] pub realm_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + +fn default_realm_name() -> String { + "".to_string() +} + impl OAuth2Keycloak { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_kick.rs b/src/models/o_auth2_kick.rs index d3f982f..12376b0 100644 --- a/src/models/o_auth2_kick.rs +++ b/src/models/o_auth2_kick.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Kick { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Kick OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Kick OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Kick { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_linkedin.rs b/src/models/o_auth2_linkedin.rs index 1c1077e..e76011f 100644 --- a/src/models/o_auth2_linkedin.rs +++ b/src/models/o_auth2_linkedin.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Linkedin { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// LinkedIn OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// LinkedIn OAuth2 primary client secret. #[serde(rename = "primaryClientSecret")] + #[serde(default = "default_primary_client_secret")] pub primary_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_primary_client_secret() -> String { + "".to_string() +} + impl OAuth2Linkedin { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_microsoft.rs b/src/models/o_auth2_microsoft.rs index 3a2535b..3aab893 100644 --- a/src/models/o_auth2_microsoft.rs +++ b/src/models/o_auth2_microsoft.rs @@ -8,26 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Microsoft { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Microsoft OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// Microsoft OAuth2 application secret. #[serde(rename = "applicationSecret")] + #[serde(default = "default_application_secret")] pub application_secret: String, /// Microsoft OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Microsoft Entra ID tenant identifier. Use 'common', 'organizations', /// 'consumers' or a specific tenant ID. #[serde(rename = "tenant")] + #[serde(default = "default_tenant")] pub tenant: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_application_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tenant() -> String { + "".to_string() +} + impl OAuth2Microsoft { /// Get id pub fn id(&self) -> &String { @@ -49,15 +78,9 @@ impl OAuth2Microsoft { &self.application_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get tenant @@ -77,6 +100,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.application_id(); let _ = _model.application_secret(); + let _ = _model.prompt(); let _ = _model.tenant(); } diff --git a/src/models/o_auth2_notion.rs b/src/models/o_auth2_notion.rs index c42807b..bb32958 100644 --- a/src/models/o_auth2_notion.rs +++ b/src/models/o_auth2_notion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Notion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Notion OAuth2 client ID. #[serde(rename = "oauthClientId")] + #[serde(default = "default_oauth_client_id")] pub oauth_client_id: String, /// Notion OAuth2 client secret. #[serde(rename = "oauthClientSecret")] + #[serde(default = "default_oauth_client_secret")] pub oauth_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth_client_id() -> String { + "".to_string() +} + +fn default_oauth_client_secret() -> String { + "".to_string() +} + impl OAuth2Notion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_oidc.rs b/src/models/o_auth2_oidc.rs index 010281d..aa2df42 100644 --- a/src/models/o_auth2_oidc.rs +++ b/src/models/o_auth2_oidc.rs @@ -8,33 +8,42 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Oidc { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OpenID Connect OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// OpenID Connect OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, + /// OpenID Connect prompt values controlling the authentication and consent + /// screens. + #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] + pub prompt: Vec, /// OpenID Connect well-known configuration URL. When set, authorization, /// token, and user info endpoints can be discovered automatically. #[serde(rename = "wellKnownURL")] + #[serde(default = "default_well_known_url")] pub well_known_url: String, /// OpenID Connect authorization endpoint URL. #[serde(rename = "authorizationURL")] + #[serde(default = "default_authorization_url")] pub authorization_url: String, /// OpenID Connect token endpoint URL. #[serde(rename = "tokenURL")] + #[serde(default = "default_token_url")] pub token_url: String, /// OpenID Connect user info endpoint URL. #[serde(rename = "userInfoURL")] + #[serde(default = "default_user_info_url")] pub user_info_url: String, - /// OpenID Connect prompt values controlling the authentication and consent - /// screens. - #[serde(rename = "prompt")] - pub prompt: Vec, /// Maximum authentication age in seconds. When set, the user must have /// authenticated within this many seconds. #[serde(rename = "maxAge")] @@ -42,6 +51,42 @@ pub struct OAuth2Oidc { pub max_age: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_well_known_url() -> String { + "".to_string() +} + +fn default_authorization_url() -> String { + "".to_string() +} + +fn default_token_url() -> String { + "".to_string() +} + +fn default_user_info_url() -> String { + "".to_string() +} + impl OAuth2Oidc { /// Get id pub fn id(&self) -> &String { @@ -63,6 +108,11 @@ impl OAuth2Oidc { &self.client_secret } + /// Get prompt + pub fn prompt(&self) -> &Vec { + &self.prompt + } + /// Get well_known_url pub fn well_known_url(&self) -> &String { &self.well_known_url @@ -83,11 +133,6 @@ impl OAuth2Oidc { &self.user_info_url } - /// Get prompt - pub fn prompt(&self) -> &Vec { - &self.prompt - } - /// Set max_age pub fn set_max_age(mut self, max_age: i64) -> Self { self.max_age = Some(max_age); @@ -111,11 +156,11 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.well_known_url(); let _ = _model.authorization_url(); let _ = _model.token_url(); let _ = _model.user_info_url(); - let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_okta.rs b/src/models/o_auth2_okta.rs index e8fdf00..be8da90 100644 --- a/src/models/o_auth2_okta.rs +++ b/src/models/o_auth2_okta.rs @@ -8,28 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Okta { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Okta OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Okta OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Okta OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Okta OAuth2 domain. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Okta OAuth2 authorization server ID. #[serde(rename = "authorizationServerId")] + #[serde(default = "default_authorization_server_id")] pub authorization_server_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_authorization_server_id() -> String { + "".to_string() +} + impl OAuth2Okta { /// Get id pub fn id(&self) -> &String { @@ -51,15 +85,9 @@ impl OAuth2Okta { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get domain @@ -84,6 +112,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.domain(); let _ = _model.authorization_server_id(); } diff --git a/src/models/o_auth2_paypal.rs b/src/models/o_auth2_paypal.rs index 41539e5..50ff622 100644 --- a/src/models/o_auth2_paypal.rs +++ b/src/models/o_auth2_paypal.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Paypal { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// PayPal OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// PayPal OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Paypal { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_podio.rs b/src/models/o_auth2_podio.rs index 87bb74a..cd87360 100644 --- a/src/models/o_auth2_podio.rs +++ b/src/models/o_auth2_podio.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Podio { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Podio OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Podio OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Podio { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_provider_list.rs b/src/models/o_auth2_provider_list.rs index a3354d1..510881c 100644 --- a/src/models/o_auth2_provider_list.rs +++ b/src/models/o_auth2_provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2ProviderList { /// Total number of OAuth2 providers in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of OAuth2 providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl OAuth2ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/o_auth2_resend.rs b/src/models/o_auth2_resend.rs index 1658315..773278e 100644 --- a/src/models/o_auth2_resend.rs +++ b/src/models/o_auth2_resend.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Resend { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Resend OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Resend OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Resend { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_salesforce.rs b/src/models/o_auth2_salesforce.rs index 4565047..addaba3 100644 --- a/src/models/o_auth2_salesforce.rs +++ b/src/models/o_auth2_salesforce.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Salesforce { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Salesforce OAuth2 consumer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// Salesforce OAuth2 consumer secret. #[serde(rename = "customerSecret")] + #[serde(default = "default_customer_secret")] pub customer_secret: String, /// Salesforce OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_customer_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Salesforce { @@ -45,15 +69,9 @@ impl OAuth2Salesforce { &self.customer_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.customer_key(); let _ = _model.customer_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_slack.rs b/src/models/o_auth2_slack.rs index 3045596..1563a50 100644 --- a/src/models/o_auth2_slack.rs +++ b/src/models/o_auth2_slack.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Slack { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Slack OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Slack OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Slack { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_spotify.rs b/src/models/o_auth2_spotify.rs index 00572b9..00d8ad3 100644 --- a/src/models/o_auth2_spotify.rs +++ b/src/models/o_auth2_spotify.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Spotify { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Spotify OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Spotify OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Spotify { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_stripe.rs b/src/models/o_auth2_stripe.rs index 5b1565d..8c7a9c0 100644 --- a/src/models/o_auth2_stripe.rs +++ b/src/models/o_auth2_stripe.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Stripe { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Stripe OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Stripe OAuth2 API secret key. #[serde(rename = "apiSecretKey")] + #[serde(default = "default_api_secret_key")] pub api_secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_api_secret_key() -> String { + "".to_string() +} + impl OAuth2Stripe { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_tradeshift.rs b/src/models/o_auth2_tradeshift.rs index ba79a82..70533ca 100644 --- a/src/models/o_auth2_tradeshift.rs +++ b/src/models/o_auth2_tradeshift.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Tradeshift { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Tradeshift OAuth2 client ID. #[serde(rename = "oauth2ClientId")] + #[serde(default = "default_oauth2_client_id")] pub oauth2_client_id: String, /// Tradeshift OAuth2 client secret. #[serde(rename = "oauth2ClientSecret")] + #[serde(default = "default_oauth2_client_secret")] pub oauth2_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth2_client_id() -> String { + "".to_string() +} + +fn default_oauth2_client_secret() -> String { + "".to_string() +} + impl OAuth2Tradeshift { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_twitch.rs b/src/models/o_auth2_twitch.rs index e0550f7..d3f246a 100644 --- a/src/models/o_auth2_twitch.rs +++ b/src/models/o_auth2_twitch.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Twitch { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Twitch OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Twitch OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Twitch { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_word_press.rs b/src/models/o_auth2_word_press.rs index a340ebc..52fb61b 100644 --- a/src/models/o_auth2_word_press.rs +++ b/src/models/o_auth2_word_press.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2WordPress { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// WordPress OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// WordPress OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2WordPress { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_x.rs b/src/models/o_auth2_x.rs index c3c4f83..8161a8e 100644 --- a/src/models/o_auth2_x.rs +++ b/src/models/o_auth2_x.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2X { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// X OAuth2 customer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// X OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2X { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yahoo.rs b/src/models/o_auth2_yahoo.rs index 18c69b1..d69e55e 100644 --- a/src/models/o_auth2_yahoo.rs +++ b/src/models/o_auth2_yahoo.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yahoo { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yahoo OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yahoo OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yahoo { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yandex.rs b/src/models/o_auth2_yandex.rs index 9db7bc6..d7e59dd 100644 --- a/src/models/o_auth2_yandex.rs +++ b/src/models/o_auth2_yandex.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yandex { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yandex OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yandex OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yandex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_zoho.rs b/src/models/o_auth2_zoho.rs index 58cef47..8477a96 100644 --- a/src/models/o_auth2_zoho.rs +++ b/src/models/o_auth2_zoho.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoho { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoho OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoho OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Zoho OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Zoho { @@ -45,15 +69,9 @@ impl OAuth2Zoho { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_zoom.rs b/src/models/o_auth2_zoom.rs index e0047c3..4c44b8d 100644 --- a/src/models/o_auth2_zoom.rs +++ b/src/models/o_auth2_zoom.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoom { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoom OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoom OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Zoom { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_approve.rs b/src/models/oauth2_approve.rs index a946f11..ac5ce43 100644 --- a/src/models/oauth2_approve.rs +++ b/src/models/oauth2_approve.rs @@ -10,9 +10,14 @@ pub struct Oauth2Approve { /// carrying the authorization `code` and/or `id_token` along with the original /// `state`. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Approve { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_authorize.rs b/src/models/oauth2_authorize.rs index 5063ed7..89f1f92 100644 --- a/src/models/oauth2_authorize.rs +++ b/src/models/oauth2_authorize.rs @@ -10,13 +10,23 @@ pub struct Oauth2Authorize { /// the approve or reject endpoint. Empty when a redirect URL is returned /// instead. #[serde(rename = "grantId")] + #[serde(default = "default_grant_id")] pub grant_id: String, /// URL the end user should be redirected to when the flow can complete without /// consent. Empty when consent is still required. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_grant_id() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Authorize { /// Get grant_id pub fn grant_id(&self) -> &String { diff --git a/src/models/oauth2_consent.rs b/src/models/oauth2_consent.rs index 995d15b..a6e4b9e 100644 --- a/src/models/oauth2_consent.rs +++ b/src/models/oauth2_consent.rs @@ -8,40 +8,90 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Consent { /// Consent ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Consent creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Consent update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the consent belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the consent was given to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the consent was given to. /// Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes the user consented to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators the user consented to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details the user consented to, as a JSON string. Each entry /// has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Consent expiration time in ISO 8601 format. Empty when the consent has no /// token-bound expiry yet. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Consent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_list.rs b/src/models/oauth2_consent_list.rs index 3982df2..b019afe 100644 --- a/src/models/oauth2_consent_list.rs +++ b/src/models/oauth2_consent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentList { /// Total number of consents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of consents. #[serde(rename = "consents")] + #[serde(default = "default_consents")] pub consents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_consents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_consent_token.rs b/src/models/oauth2_consent_token.rs index 4d2f43f..776ba73 100644 --- a/src/models/oauth2_consent_token.rs +++ b/src/models/oauth2_consent_token.rs @@ -8,44 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentToken { /// Token family ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Token update date in ISO 8601 format. Refreshing the token family updates /// this. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the consent the token family was issued under. #[serde(rename = "consentId")] + #[serde(default = "default_consent_id")] pub consent_id: String, /// ID of the user the token family belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the token family was issued to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the token family was issued /// to. Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes granted on the token family. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators granted on the token family. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details granted on the token family, as a JSON string. Each /// entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Expiration time of the current access token of this family in ISO 8601 /// format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_consent_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2ConsentToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_token_list.rs b/src/models/oauth2_consent_token_list.rs index 9f5f5ad..906b8e2 100644 --- a/src/models/oauth2_consent_token_list.rs +++ b/src/models/oauth2_consent_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_device_authorization.rs b/src/models/oauth2_device_authorization.rs index 80feee2..f0bef4d 100644 --- a/src/models/oauth2_device_authorization.rs +++ b/src/models/oauth2_device_authorization.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2DeviceAuthorization { /// Device verification code used by the client to poll the token endpoint. #[serde(rename = "device_code")] + #[serde(default = "default_device_code")] pub device_code: String, /// Short code the end user enters on the verification page. #[serde(rename = "user_code")] + #[serde(default = "default_user_code")] pub user_code: String, /// URL where the end user enters the user code. #[serde(rename = "verification_uri")] + #[serde(default = "default_verification_uri")] pub verification_uri: String, /// Verification URL with the user code prefilled as a query parameter. #[serde(rename = "verification_uri_complete")] + #[serde(default = "default_verification_uri_complete")] pub verification_uri_complete: String, /// Lifetime of the device code and user code in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// Minimum polling interval for the token endpoint in seconds. #[serde(rename = "interval")] + #[serde(default = "default_interval")] pub interval: i64, } +fn default_device_code() -> String { + "".to_string() +} + +fn default_user_code() -> String { + "".to_string() +} + +fn default_verification_uri() -> String { + "".to_string() +} + +fn default_verification_uri_complete() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_interval() -> i64 { + 0 +} + impl Oauth2DeviceAuthorization { /// Get device_code pub fn device_code(&self) -> &String { diff --git a/src/models/oauth2_grant.rs b/src/models/oauth2_grant.rs index 16d716d..b6e37b0 100644 --- a/src/models/oauth2_grant.rs +++ b/src/models/oauth2_grant.rs @@ -8,45 +8,105 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Grant { /// Grant ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Grant creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Grant update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the grant belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the OAuth2 client (app) the grant was requested for. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Requested OAuth2 scopes the user is being asked to consent to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Requested RFC 8707 resource indicators the user is being asked to consent /// to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Requested authorization_details the user is being asked to consent to, as a /// JSON string. Each entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// OIDC prompt directive the consent screen should honor. Space-separated list /// of: login, consent, select_account. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: String, /// Redirect URI the user will be sent to after the flow completes. #[serde(rename = "redirectUri")] + #[serde(default = "default_redirect_uri")] pub redirect_uri: String, /// Unix timestamp of when the user last authenticated. #[serde(rename = "authTime")] + #[serde(default = "default_auth_time")] pub auth_time: i64, /// Grant expiration time in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_prompt() -> String { + "".to_string() +} + +fn default_redirect_uri() -> String { + "".to_string() +} + +fn default_auth_time() -> i64 { + 0 +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Grant { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization.rs b/src/models/oauth2_organization.rs index b2c20fc..ff1bf2b 100644 --- a/src/models/oauth2_organization.rs +++ b/src/models/oauth2_organization.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Organization { /// Organization ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, } +fn default_id() -> String { + "".to_string() +} + impl Oauth2Organization { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization_list.rs b/src/models/oauth2_organization_list.rs index 1309964..0188ebd 100644 --- a/src/models/oauth2_organization_list.rs +++ b/src/models/oauth2_organization_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2OrganizationList { /// Total number of organizations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of organizations. #[serde(rename = "organizations")] + #[serde(default = "default_organizations")] pub organizations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_organizations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2OrganizationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_par.rs b/src/models/oauth2_par.rs index f1d779e..09e366f 100644 --- a/src/models/oauth2_par.rs +++ b/src/models/oauth2_par.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2PAR { /// Authorization request handle to pass to the authorize endpoint. #[serde(rename = "request_uri")] + #[serde(default = "default_request_uri")] pub request_uri: String, /// Lifetime of the authorization request handle in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, } +fn default_request_uri() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + impl Oauth2PAR { /// Get request_uri pub fn request_uri(&self) -> &String { diff --git a/src/models/oauth2_project.rs b/src/models/oauth2_project.rs index 5af4e85..78ea717 100644 --- a/src/models/oauth2_project.rs +++ b/src/models/oauth2_project.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Region ID the project is deployed in. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// API endpoint of the region the project is deployed in. Empty when the /// region has no public hostname configured. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl Oauth2Project { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_project_list.rs b/src/models/oauth2_project_list.rs index 2e849fb..3e8b16c 100644 --- a/src/models/oauth2_project_list.rs +++ b/src/models/oauth2_project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_reject.rs b/src/models/oauth2_reject.rs index 5daab49..7051bb4 100644 --- a/src/models/oauth2_reject.rs +++ b/src/models/oauth2_reject.rs @@ -9,9 +9,14 @@ pub struct Oauth2Reject { /// URL the end user should be redirected to after the grant is rejected, /// carrying an `access_denied` error. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Reject { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_token.rs b/src/models/oauth2_token.rs index 37b8552..9c647fb 100644 --- a/src/models/oauth2_token.rs +++ b/src/models/oauth2_token.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Token { /// OAuth2 access token. #[serde(rename = "access_token")] + #[serde(default = "default_access_token")] pub access_token: String, /// OAuth2 token type. #[serde(rename = "token_type")] + #[serde(default = "default_token_type")] pub token_type: String, /// Access token lifetime in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// OAuth2 refresh token. #[serde(rename = "refresh_token")] + #[serde(default = "default_refresh_token")] pub refresh_token: String, /// Space-separated scopes granted to the access token. #[serde(rename = "scope")] + #[serde(default = "default_scope")] pub scope: String, /// Granted RFC 9396 authorization details as a JSON string. #[serde(rename = "authorization_details")] @@ -31,6 +36,26 @@ pub struct Oauth2Token { pub id_token: Option, } +fn default_access_token() -> String { + "".to_string() +} + +fn default_token_type() -> String { + "Bearer".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_refresh_token() -> String { + "".to_string() +} + +fn default_scope() -> String { + "".to_string() +} + impl Oauth2Token { /// Get access_token pub fn access_token(&self) -> &String { diff --git a/src/models/organization.rs b/src/models/organization.rs index f7ec61d..82eeded 100644 --- a/src/models/organization.rs +++ b/src/models/organization.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Organization { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] @@ -30,44 +35,55 @@ pub struct Organization { pub billing_budget: Option, /// Project budget limit #[serde(rename = "budgetAlerts")] + #[serde(default = "default_budget_alerts")] pub budget_alerts: Vec, /// Organization's billing plan ID. #[serde(rename = "billingPlan")] + #[serde(default = "default_billing_plan")] pub billing_plan: String, /// Organization's billing plan ID. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, /// Organization's billing plan. #[serde(rename = "billingPlanDetails")] pub billing_plan_details: crate::models::BillingPlan, /// Billing email set for the organization. #[serde(rename = "billingEmail")] + #[serde(default = "default_billing_email")] pub billing_email: String, /// Billing cycle start date. #[serde(rename = "billingStartDate")] - pub billing_start_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_start_date: Option, /// Current invoice cycle start date. #[serde(rename = "billingCurrentInvoiceDate")] - pub billing_current_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_current_invoice_date: Option, /// Next invoice cycle start date. #[serde(rename = "billingNextInvoiceDate")] - pub billing_next_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_next_invoice_date: Option, /// Start date of trial. #[serde(rename = "billingTrialStartDate")] #[serde(skip_serializing_if = "Option::is_none")] pub billing_trial_start_date: Option, /// Number of trial days. #[serde(rename = "billingTrialDays")] - pub billing_trial_days: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_trial_days: Option, /// Current active aggregation id. #[serde(rename = "billingAggregationId")] - pub billing_aggregation_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_aggregation_id: Option, /// Current active aggregation id. #[serde(rename = "billingInvoiceId")] - pub billing_invoice_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_invoice_id: Option, /// Default payment method. #[serde(rename = "paymentMethodId")] - pub payment_method_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_id: Option, /// Default payment method. #[serde(rename = "billingAddressId")] #[serde(skip_serializing_if = "Option::is_none")] @@ -78,6 +94,7 @@ pub struct Organization { pub backup_payment_method_id: Option, /// Team status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Remarks on team status. #[serde(rename = "remarks")] @@ -117,15 +134,70 @@ pub struct Organization { pub billing_tax_id: Option, /// Marked for deletion #[serde(rename = "markedForDeletion")] + #[serde(default = "default_marked_for_deletion")] pub marked_for_deletion: bool, /// Product with which the organization is associated (appwrite or imagine) #[serde(rename = "platform")] + #[serde(default = "default_platform")] pub platform: String, /// Selected projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + +fn default_budget_alerts() -> Vec { + serde_json::from_value(serde_json::json!([75])).unwrap() +} + +fn default_billing_plan() -> String { + "tier-0".to_string() +} + +fn default_billing_plan_id() -> String { + "tier-0".to_string() +} + +fn default_billing_email() -> String { + "".to_string() +} + +fn default_status() -> String { + "draft".to_string() +} + +fn default_marked_for_deletion() -> bool { + false +} + +fn default_platform() -> String { + "appwrite".to_string() +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Organization { /// Get id pub fn id(&self) -> &String { @@ -193,19 +265,40 @@ impl Organization { &self.billing_email } + /// Set billing_start_date + pub fn set_billing_start_date(mut self, billing_start_date: String) -> Self { + self.billing_start_date = Some(billing_start_date); + self + } + /// Get billing_start_date - pub fn billing_start_date(&self) -> &String { - &self.billing_start_date + pub fn billing_start_date(&self) -> Option<&String> { + self.billing_start_date.as_ref() + } + + /// Set billing_current_invoice_date + pub fn set_billing_current_invoice_date( + mut self, + billing_current_invoice_date: String, + ) -> Self { + self.billing_current_invoice_date = Some(billing_current_invoice_date); + self } /// Get billing_current_invoice_date - pub fn billing_current_invoice_date(&self) -> &String { - &self.billing_current_invoice_date + pub fn billing_current_invoice_date(&self) -> Option<&String> { + self.billing_current_invoice_date.as_ref() + } + + /// Set billing_next_invoice_date + pub fn set_billing_next_invoice_date(mut self, billing_next_invoice_date: String) -> Self { + self.billing_next_invoice_date = Some(billing_next_invoice_date); + self } /// Get billing_next_invoice_date - pub fn billing_next_invoice_date(&self) -> &String { - &self.billing_next_invoice_date + pub fn billing_next_invoice_date(&self) -> Option<&String> { + self.billing_next_invoice_date.as_ref() } /// Set billing_trial_start_date @@ -219,24 +312,48 @@ impl Organization { self.billing_trial_start_date.as_ref() } + /// Set billing_trial_days + pub fn set_billing_trial_days(mut self, billing_trial_days: i64) -> Self { + self.billing_trial_days = Some(billing_trial_days); + self + } + /// Get billing_trial_days - pub fn billing_trial_days(&self) -> &i64 { - &self.billing_trial_days + pub fn billing_trial_days(&self) -> Option<&i64> { + self.billing_trial_days.as_ref() + } + + /// Set billing_aggregation_id + pub fn set_billing_aggregation_id(mut self, billing_aggregation_id: String) -> Self { + self.billing_aggregation_id = Some(billing_aggregation_id); + self } /// Get billing_aggregation_id - pub fn billing_aggregation_id(&self) -> &String { - &self.billing_aggregation_id + pub fn billing_aggregation_id(&self) -> Option<&String> { + self.billing_aggregation_id.as_ref() + } + + /// Set billing_invoice_id + pub fn set_billing_invoice_id(mut self, billing_invoice_id: String) -> Self { + self.billing_invoice_id = Some(billing_invoice_id); + self } /// Get billing_invoice_id - pub fn billing_invoice_id(&self) -> &String { - &self.billing_invoice_id + pub fn billing_invoice_id(&self) -> Option<&String> { + self.billing_invoice_id.as_ref() + } + + /// Set payment_method_id + pub fn set_payment_method_id(mut self, payment_method_id: String) -> Self { + self.payment_method_id = Some(payment_method_id); + self } /// Get payment_method_id - pub fn payment_method_id(&self) -> &String { - &self.payment_method_id + pub fn payment_method_id(&self) -> Option<&String> { + self.payment_method_id.as_ref() } /// Set billing_address_id @@ -402,13 +519,6 @@ mod tests { let _ = _model.billing_plan_id(); let _ = _model.billing_plan_details(); let _ = _model.billing_email(); - let _ = _model.billing_start_date(); - let _ = _model.billing_current_invoice_date(); - let _ = _model.billing_next_invoice_date(); - let _ = _model.billing_trial_days(); - let _ = _model.billing_aggregation_id(); - let _ = _model.billing_invoice_id(); - let _ = _model.payment_method_id(); let _ = _model.status(); let _ = _model.marked_for_deletion(); let _ = _model.platform(); diff --git a/src/models/passkey.rs b/src/models/passkey.rs index 0685af4..9f9afb4 100644 --- a/src/models/passkey.rs +++ b/src/models/passkey.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct Passkey { /// Passkey ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Passkey creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Passkey update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Passkey name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Most recent sign-in with this passkey in ISO 8601 format. Empty until the /// passkey is used to sign in. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl Passkey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_challenge.rs b/src/models/passkey_challenge.rs index 8ecada5..a0cffe5 100644 --- a/src/models/passkey_challenge.rs +++ b/src/models/passkey_challenge.rs @@ -9,23 +9,48 @@ pub struct PasskeyChallenge { /// Challenge ID. When signing in, pass it back with the credential to receive /// a token. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Challenge creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// ID of the passkey being registered. Empty for sign-in challenges. #[serde(rename = "passkeyId")] + #[serde(default = "default_passkey_id")] pub passkey_id: String, /// Challenge expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// WebAuthn options in JSON form. Pass them to /// `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or /// `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: serde_json::Value, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_passkey_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_public_key() -> serde_json::Value { + serde_json::json!({}) +} + impl PasskeyChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_list.rs b/src/models/passkey_list.rs index 8b9e05e..5f9a82c 100644 --- a/src/models/passkey_list.rs +++ b/src/models/passkey_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PasskeyList { /// Total number of passkeys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of passkeys. #[serde(rename = "passkeys")] + #[serde(default = "default_passkeys")] pub passkeys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_passkeys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PasskeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/phone.rs b/src/models/phone.rs index 2d6a27c..f06631b 100644 --- a/src/models/phone.rs +++ b/src/models/phone.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Phone { /// Phone code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + impl Phone { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/phone_list.rs b/src/models/phone_list.rs index 53939ae..b17138c 100644 --- a/src/models/phone_list.rs +++ b/src/models/phone_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PhoneList { /// Total number of phones that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of phones. #[serde(rename = "phones")] + #[serde(default = "default_phones")] pub phones: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_phones() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PhoneList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_android.rs b/src/models/platform_android.rs index 7f35a47..28a4ac1 100644 --- a/src/models/platform_android.rs +++ b/src/models/platform_android.rs @@ -8,27 +8,56 @@ use serde::{Deserialize, Serialize}; pub struct PlatformAndroid { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Android application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// SHA-256 fingerprints of the certificates the app is signed with. Passkeys /// created in the app are accepted when its signature matches one. #[serde(rename = "fingerprints")] - #[serde(skip_serializing_if = "Option::is_none")] - pub fingerprints: Option>, + #[serde(default = "default_fingerprints")] + pub fingerprints: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_fingerprints() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl PlatformAndroid { @@ -62,15 +91,9 @@ impl PlatformAndroid { &self.application_id } - /// Set fingerprints - pub fn set_fingerprints(mut self, fingerprints: Vec) -> Self { - self.fingerprints = Some(fingerprints); - self - } - /// Get fingerprints - pub fn fingerprints(&self) -> Option<&Vec> { - self.fingerprints.as_ref() + pub fn fingerprints(&self) -> &Vec { + &self.fingerprints } } @@ -87,6 +110,7 @@ mod tests { let _ = _model.name(); let _ = _model.r#type(); let _ = _model.application_id(); + let _ = _model.fingerprints(); } #[test] diff --git a/src/models/platform_apple.rs b/src/models/platform_apple.rs index c157274..fd57555 100644 --- a/src/models/platform_apple.rs +++ b/src/models/platform_apple.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformApple { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Apple bundle identifier. #[serde(rename = "bundleIdentifier")] + #[serde(default = "default_bundle_identifier")] pub bundle_identifier: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_bundle_identifier() -> String { + "".to_string() +} + impl PlatformApple { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_linux.rs b/src/models/platform_linux.rs index d305b51..db7b998 100644 --- a/src/models/platform_linux.rs +++ b/src/models/platform_linux.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformLinux { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Linux package name. #[serde(rename = "packageName")] + #[serde(default = "default_package_name")] pub package_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_name() -> String { + "".to_string() +} + impl PlatformLinux { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_list.rs b/src/models/platform_list.rs index 523fc50..5caaee7 100644 --- a/src/models/platform_list.rs +++ b/src/models/platform_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PlatformList { /// Total number of platforms in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of platforms. #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_platforms() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PlatformList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_web.rs b/src/models/platform_web.rs index 5daea92..a35b4c5 100644 --- a/src/models/platform_web.rs +++ b/src/models/platform_web.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWeb { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Web app hostname. Empty string for other platforms. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + impl PlatformWeb { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_windows.rs b/src/models/platform_windows.rs index da5c08f..52d9c7a 100644 --- a/src/models/platform_windows.rs +++ b/src/models/platform_windows.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWindows { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Windows package identifier name. #[serde(rename = "packageIdentifierName")] + #[serde(default = "default_package_identifier_name")] pub package_identifier_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_identifier_name() -> String { + "".to_string() +} + impl PlatformWindows { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_aliased_email.rs b/src/models/policy_deny_aliased_email.rs index c7327b0..bca4bde 100644 --- a/src/models/policy_deny_aliased_email.rs +++ b/src/models/policy_deny_aliased_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyAliasedEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny aliased email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyAliasedEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_corporate_email.rs b/src/models/policy_deny_corporate_email.rs index 8b271b9..b90e444 100644 --- a/src/models/policy_deny_corporate_email.rs +++ b/src/models/policy_deny_corporate_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyCorporateEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny non-corporate email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyCorporateEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_disposable_email.rs b/src/models/policy_deny_disposable_email.rs index 029a4fe..3cfb4ec 100644 --- a/src/models/policy_deny_disposable_email.rs +++ b/src/models/policy_deny_disposable_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyDisposableEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny disposable email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyDisposableEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_free_email.rs b/src/models/policy_deny_free_email.rs index 6038f66..5c1b61d 100644 --- a/src/models/policy_deny_free_email.rs +++ b/src/models/policy_deny_free_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyFreeEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny free email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyFreeEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_list.rs b/src/models/policy_list.rs index 559b319..cec5f0b 100644 --- a/src/models/policy_list.rs +++ b/src/models/policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyList { /// Total number of policies in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/policy_membership_privacy.rs b/src/models/policy_membership_privacy.rs index 8b17314..c42cc90 100644 --- a/src/models/policy_membership_privacy.rs +++ b/src/models/policy_membership_privacy.rs @@ -8,27 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMembershipPrivacy { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether user ID is visible in memberships. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: bool, /// Whether user email is visible in memberships. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: bool, /// Whether user phone is visible in memberships. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: bool, /// Whether user name is visible in memberships. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: bool, /// Whether user MFA status is visible in memberships. #[serde(rename = "userMFA")] + #[serde(default = "default_user_mfa")] pub user_mfa: bool, /// Whether user last access time is visible in memberships. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_user_id() -> bool { + false +} + +fn default_user_email() -> bool { + false +} + +fn default_user_phone() -> bool { + false +} + +fn default_user_name() -> bool { + false +} + +fn default_user_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> bool { + false +} + impl PolicyMembershipPrivacy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_mfa_factors.rs b/src/models/policy_mfa_factors.rs index a6634b6..5d6a1f3 100644 --- a/src/models/policy_mfa_factors.rs +++ b/src/models/policy_mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMfaFactors { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether TOTP can be used to complete an MFA challenge. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Whether email can be used to complete an MFA challenge. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Whether phone (SMS) can be used to complete an MFA challenge. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Whether the custom factor can be used to complete an MFA challenge. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_totp() -> bool { + true +} + +fn default_email() -> bool { + true +} + +fn default_phone() -> bool { + true +} + +fn default_custom() -> bool { + false +} + impl PolicyMfaFactors { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_passkey.rs b/src/models/policy_passkey.rs index 3306d5e..e556cbc 100644 --- a/src/models/policy_passkey.rs +++ b/src/models/policy_passkey.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasskey { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Relying party ID passkeys are bound to. Empty until configured. #[serde(rename = "rpId")] + #[serde(default = "default_rp_id")] pub rp_id: String, /// Web origins passkeys work on, from the project's platforms on the relying /// party ID and a localhost web platform. Read-only. #[serde(rename = "origins")] + #[serde(default = "default_origins")] pub origins: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_rp_id() -> String { + "".to_string() +} + +fn default_origins() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyPasskey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_dictionary.rs b/src/models/policy_password_dictionary.rs index e14d27b..2d9857d 100644 --- a/src/models/policy_password_dictionary.rs +++ b/src/models/policy_password_dictionary.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordDictionary { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password dictionary policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordDictionary { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_history.rs b/src/models/policy_password_history.rs index 6f00db0..e356b25 100644 --- a/src/models/policy_password_history.rs +++ b/src/models/policy_password_history.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordHistory { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Password history length. A value of 0 means the policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyPasswordHistory { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_personal_data.rs b/src/models/policy_password_personal_data.rs index 6fee0df..9b19000 100644 --- a/src/models/policy_password_personal_data.rs +++ b/src/models/policy_password_personal_data.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordPersonalData { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password personal data policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordPersonalData { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_strength.rs b/src/models/policy_password_strength.rs index fa3b56a..08ff7bb 100644 --- a/src/models/policy_password_strength.rs +++ b/src/models/policy_password_strength.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordStrength { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Minimum password length required for user passwords. #[serde(rename = "min")] + #[serde(default = "default_min")] pub min: i64, /// Whether passwords must include at least one uppercase letter. #[serde(rename = "uppercase")] + #[serde(default = "default_uppercase")] pub uppercase: bool, /// Whether passwords must include at least one lowercase letter. #[serde(rename = "lowercase")] + #[serde(default = "default_lowercase")] pub lowercase: bool, /// Whether passwords must include at least one number. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: bool, /// Whether passwords must include at least one symbol. #[serde(rename = "symbols")] + #[serde(default = "default_symbols")] pub symbols: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_min() -> i64 { + 8 +} + +fn default_uppercase() -> bool { + false +} + +fn default_lowercase() -> bool { + false +} + +fn default_number() -> bool { + false +} + +fn default_symbols() -> bool { + false +} + impl PolicyPasswordStrength { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_alert.rs b/src/models/policy_session_alert.rs index 3689003..84ebba2 100644 --- a/src/models/policy_session_alert.rs +++ b/src/models/policy_session_alert.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionAlert { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session alert policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicySessionAlert { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_duration.rs b/src/models/policy_session_duration.rs index 4cf1a79..93e96dc 100644 --- a/src/models/policy_session_duration.rs +++ b/src/models/policy_session_duration.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionDuration { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session duration in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_duration() -> i64 { + 31536000 +} + impl PolicySessionDuration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_invalidation.rs b/src/models/policy_session_invalidation.rs index 07846c9..f63d898 100644 --- a/src/models/policy_session_invalidation.rs +++ b/src/models/policy_session_invalidation.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionInvalidation { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session invalidation policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + impl PolicySessionInvalidation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_limit.rs b/src/models/policy_session_limit.rs index 86f066f..c6b02b8 100644 --- a/src/models/policy_session_limit.rs +++ b/src/models/policy_session_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of sessions allowed per user. A value of 0 means the policy /// is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicySessionLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_user_limit.rs b/src/models/policy_user_limit.rs index 4515afd..84b0359 100644 --- a/src/models/policy_user_limit.rs +++ b/src/models/policy_user_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicyUserLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of users allowed in the project. A value of 0 means the /// policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyUserLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/postgres_extension.rs b/src/models/postgres_extension.rs index 6fa2b95..8e2cb31 100644 --- a/src/models/postgres_extension.rs +++ b/src/models/postgres_extension.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct PostgresExtension { /// Extension key used with CREATE EXTENSION. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Human-readable extension name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Short description of what the extension provides. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Category the extension belongs to. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + impl PostgresExtension { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/presence.rs b/src/models/presence.rs index 5ed34d4..845310e 100644 --- a/src/models/presence.rs +++ b/src/models/presence.rs @@ -8,19 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct Presence { /// Presence ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Presence creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Presence update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Presence permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Presence status. #[serde(rename = "status")] @@ -28,6 +33,7 @@ pub struct Presence { pub status: Option, /// Presence source. #[serde(rename = "source")] + #[serde(default = "default_source")] pub source: String, /// Presence expiry date in ISO 8601 format. #[serde(rename = "expiresAt")] @@ -39,6 +45,30 @@ pub struct Presence { pub metadata: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_source() -> String { + "".to_string() +} + impl Presence { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/presence_list.rs b/src/models/presence_list.rs index 0257bf7..6a006b2 100644 --- a/src/models/presence_list.rs +++ b/src/models/presence_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PresenceList { /// Total number of presences that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of presences. #[serde(rename = "presences")] + #[serde(default = "default_presences")] pub presences: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_presences() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PresenceList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/program.rs b/src/models/program.rs index 588d509..06eedf7 100644 --- a/src/models/program.rs +++ b/src/models/program.rs @@ -8,33 +8,78 @@ use serde::{Deserialize, Serialize}; pub struct Program { /// Program ID #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Program title #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Program description #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Program tag for highlighting on console #[serde(rename = "tag")] + #[serde(default = "default_tag")] pub tag: String, /// Program icon for highlighting on console #[serde(rename = "icon")] + #[serde(default = "default_icon")] pub icon: String, /// URL for more information on this program #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Whether this program is active #[serde(rename = "active")] + #[serde(default = "default_active")] pub active: bool, /// Whether this program is external #[serde(rename = "external")] + #[serde(default = "default_external")] pub external: bool, /// Billing plan ID that this is program is associated with. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_tag() -> String { + "".to_string() +} + +fn default_icon() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_active() -> bool { + true +} + +fn default_external() -> bool { + true +} + +fn default_billing_plan_id() -> String { + "".to_string() +} + impl Program { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/project.rs b/src/models/project.rs index 78a7fc7..962b910 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -8,87 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Project creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Project update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Project team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Project region #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, - /// Deprecated since 1.9.5: List of dev keys. - #[serde(rename = "devKeys")] - pub dev_keys: Vec, /// Status for custom SMTP #[serde(rename = "smtpEnabled")] + #[serde(default = "default_smtp_enabled")] pub smtp_enabled: bool, /// SMTP sender name #[serde(rename = "smtpSenderName")] + #[serde(default = "default_smtp_sender_name")] pub smtp_sender_name: String, /// SMTP sender email #[serde(rename = "smtpSenderEmail")] + #[serde(default = "default_smtp_sender_email")] pub smtp_sender_email: String, /// SMTP reply to name #[serde(rename = "smtpReplyToName")] + #[serde(default = "default_smtp_reply_to_name")] pub smtp_reply_to_name: String, /// SMTP reply to email #[serde(rename = "smtpReplyToEmail")] + #[serde(default = "default_smtp_reply_to_email")] pub smtp_reply_to_email: String, /// SMTP server host name #[serde(rename = "smtpHost")] + #[serde(default = "default_smtp_host")] pub smtp_host: String, /// SMTP server port #[serde(rename = "smtpPort")] + #[serde(default = "default_smtp_port")] pub smtp_port: i64, /// SMTP server username #[serde(rename = "smtpUsername")] + #[serde(default = "default_smtp_username")] pub smtp_username: String, /// SMTP server password. This property is write-only and always returned /// empty. #[serde(rename = "smtpPassword")] + #[serde(default = "default_smtp_password")] pub smtp_password: String, /// SMTP server secure protocol #[serde(rename = "smtpSecure")] + #[serde(default = "default_smtp_secure")] pub smtp_secure: String, /// Number of times the ping was received for this project. #[serde(rename = "pingCount")] + #[serde(default = "default_ping_count")] pub ping_count: i64, /// Last ping datetime in ISO 8601 format. #[serde(rename = "pingedAt")] + #[serde(default = "default_pinged_at")] pub pinged_at: String, /// Labels for the project. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Project status #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Stage progress (completed or skipped) with timestamps and actor types, /// keyed by stage id. #[serde(rename = "onboarding")] + #[serde(default = "default_onboarding")] pub onboarding: serde_json::Value, /// List of auth methods. #[serde(rename = "authMethods")] + #[serde(default = "default_auth_methods")] pub auth_methods: Vec, /// List of services. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// List of protocols. #[serde(rename = "protocols")] + #[serde(default = "default_protocols")] pub protocols: Vec, /// Project blocks information #[serde(rename = "blocks")] + #[serde(default = "default_blocks")] pub blocks: Vec, /// Last time the project was accessed via console. Used with plan's /// projectInactivityDays to determine if project is paused. #[serde(rename = "consoleAccessedAt")] + #[serde(default = "default_console_accessed_at")] pub console_accessed_at: String, /// Whether WAF enforcement is enabled for the project. #[serde(rename = "wafEnabled")] @@ -192,6 +215,110 @@ pub struct Project { pub o_auth2_server_discovery_url: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "fra".to_string() +} + +fn default_smtp_enabled() -> bool { + false +} + +fn default_smtp_sender_name() -> String { + "".to_string() +} + +fn default_smtp_sender_email() -> String { + "".to_string() +} + +fn default_smtp_reply_to_name() -> String { + "".to_string() +} + +fn default_smtp_reply_to_email() -> String { + "".to_string() +} + +fn default_smtp_host() -> String { + "".to_string() +} + +fn default_smtp_port() -> i64 { + 0 +} + +fn default_smtp_username() -> String { + "".to_string() +} + +fn default_smtp_password() -> String { + "".to_string() +} + +fn default_smtp_secure() -> String { + "".to_string() +} + +fn default_ping_count() -> i64 { + 0 +} + +fn default_pinged_at() -> String { + "".to_string() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_onboarding() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_auth_methods() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_protocols() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_blocks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_console_accessed_at() -> String { + "".to_string() +} + impl Project { /// Get id pub fn id(&self) -> &String { @@ -223,11 +350,6 @@ impl Project { &self.region } - /// Get dev_keys - pub fn dev_keys(&self) -> &Vec { - &self.dev_keys - } - /// Get smtp_enabled pub fn smtp_enabled(&self) -> &bool { &self.smtp_enabled @@ -634,7 +756,6 @@ mod tests { let _ = _model.name(); let _ = _model.team_id(); let _ = _model.region(); - let _ = _model.dev_keys(); let _ = _model.smtp_enabled(); let _ = _model.smtp_sender_name(); let _ = _model.smtp_sender_email(); diff --git a/src/models/project_auth_method.rs b/src/models/project_auth_method.rs index e8428f1..37f1ef8 100644 --- a/src/models/project_auth_method.rs +++ b/src/models/project_auth_method.rs @@ -11,9 +11,14 @@ pub struct ProjectAuthMethod { pub id: crate::enums::ProjectAuthMethodId, /// Auth method status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectAuthMethod { /// Get id pub fn id(&self) -> &crate::enums::ProjectAuthMethodId { diff --git a/src/models/project_list.rs b/src/models/project_list.rs index 9bcda60..83f9fdc 100644 --- a/src/models/project_list.rs +++ b/src/models/project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/project_protocol.rs b/src/models/project_protocol.rs index a8bd9e1..82cf49e 100644 --- a/src/models/project_protocol.rs +++ b/src/models/project_protocol.rs @@ -11,9 +11,14 @@ pub struct ProjectProtocol { pub id: crate::enums::ProjectProtocolId, /// Protocol status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectProtocol { /// Get id pub fn id(&self) -> &crate::enums::ProjectProtocolId { diff --git a/src/models/project_service.rs b/src/models/project_service.rs index 4d94d38..7601ae4 100644 --- a/src/models/project_service.rs +++ b/src/models/project_service.rs @@ -11,9 +11,14 @@ pub struct ProjectService { pub id: crate::enums::ProjectServiceId, /// Service status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectService { /// Get id pub fn id(&self) -> &crate::enums::ProjectServiceId { diff --git a/src/models/provider.rs b/src/models/provider.rs index 6da6a12..0730ec8 100644 --- a/src/models/provider.rs +++ b/src/models/provider.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Provider { /// Provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Provider creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Provider update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name for the provider instance. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// The name of the provider service. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Is provider enabled? #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Type of provider. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Provider credentials. #[serde(rename = "credentials")] + #[serde(default = "default_credentials")] pub credentials: serde_json::Value, /// Provider options. #[serde(rename = "options")] @@ -36,6 +44,38 @@ pub struct Provider { pub options: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "".to_string() +} + +fn default_credentials() -> serde_json::Value { + serde_json::json!({}) +} + impl Provider { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/provider_list.rs b/src/models/provider_list.rs index 3d9c5c9..8d6e077 100644 --- a/src/models/provider_list.rs +++ b/src/models/provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProviderList { /// Total number of providers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/proxy_invalidation.rs b/src/models/proxy_invalidation.rs index eaec944..575f927 100644 --- a/src/models/proxy_invalidation.rs +++ b/src/models/proxy_invalidation.rs @@ -8,19 +8,39 @@ use serde::{Deserialize, Serialize}; pub struct ProxyInvalidation { /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Invalidation type. Possible values are "tag", "path", or "all". #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Invalidated reference. Depending on type this is a cache tag name, a URL /// path, or empty when type is all. #[serde(rename = "reference")] + #[serde(default = "default_reference")] pub reference: String, /// Invalidation status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, } +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_reference() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl ProxyInvalidation { /// Get domain pub fn domain(&self) -> &String { diff --git a/src/models/proxy_rule.rs b/src/models/proxy_rule.rs index 1082f77..41571e0 100644 --- a/src/models/proxy_rule.rs +++ b/src/models/proxy_rule.rs @@ -8,58 +8,122 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRule { /// Rule ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Rule creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Rule update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Action definition for the rule. Possible values are "api", "deployment", or /// "redirect" #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Defines how the rule was created. Possible values are "manual" or /// "deployment" #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// URL to redirect to. Used if type is "redirect" #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, /// Status code to apply during redirect. Used if type is "redirect" #[serde(rename = "redirectStatusCode")] + #[serde(default = "default_redirect_status_code")] pub redirect_status_code: i64, /// ID of deployment. Used if type is "deployment" #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, - /// Type of deployment. Possible values are "function", "site". Used if rule's - /// type is "deployment". + /// Type of deployment resource: function, site, or dedicatedDatabase. #[serde(rename = "deploymentResourceType")] #[serde(skip_serializing_if = "Option::is_none")] pub deployment_resource_type: Option, /// ID of deployment's resource (site or function ID). Used if type is /// "deployment" #[serde(rename = "deploymentResourceId")] + #[serde(default = "default_deployment_resource_id")] pub deployment_resource_id: String, /// Name of Git branch that updates rule. Used if type is "deployment" #[serde(rename = "deploymentVcsProviderBranch")] + #[serde(default = "default_deployment_vcs_provider_branch")] pub deployment_vcs_provider_branch: String, /// Domain verification status. Possible values are "unverified", "verifying", /// "verified" #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::ProxyRuleStatus, /// Logs from rule verification or certificate generation. Certificate /// generation logs are prioritized if both are available. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Certificate auto-renewal date in ISO 8601 format. #[serde(rename = "renewAt")] pub renew_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + +fn default_redirect_status_code() -> i64 { + 301 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_resource_id() -> String { + "".to_string() +} + +fn default_deployment_vcs_provider_branch() -> String { + "".to_string() +} + +fn default_status() -> crate::enums::ProxyRuleStatus { + serde_json::from_value(serde_json::json!("unverified")).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + impl ProxyRule { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/proxy_rule_list.rs b/src/models/proxy_rule_list.rs index ddd137d..e6ac600 100644 --- a/src/models/proxy_rule_list.rs +++ b/src/models/proxy_rule_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRuleList { /// Total number of rules that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rules. #[serde(rename = "rules")] + #[serde(default = "default_rules")] pub rules: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rules() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProxyRuleList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/report.rs b/src/models/report.rs index 4f43770..f1992ae 100644 --- a/src/models/report.rs +++ b/src/models/report.rs @@ -8,38 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Report { /// Report ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Report creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Report update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the third-party app that submitted the report. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Analyzer that produced this report. e.g. lighthouse, audit, /// databaseAnalyzer. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Short, human-readable title for the report. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Markdown summary describing the report. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// Plural noun describing what the report analyzes, e.g. databases, sites, /// urls. #[serde(rename = "targetType")] + #[serde(default = "default_target_type")] pub target_type: String, /// Free-form target identifier (URL for lighthouse, resource ID for db). #[serde(rename = "target")] + #[serde(default = "default_target")] pub target: String, /// Categories covered by the report, e.g. performance, accessibility. #[serde(rename = "categories")] + #[serde(default = "default_categories")] pub categories: Vec, /// Insights nested under this report. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, /// Time the report was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -47,6 +58,50 @@ pub struct Report { pub analyzed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_target_type() -> String { + "".to_string() +} + +fn default_target() -> String { + "".to_string() +} + +fn default_categories() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Report { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/report_list.rs b/src/models/report_list.rs index 81b4995..4c1c5ca 100644 --- a/src/models/report_list.rs +++ b/src/models/report_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ReportList { /// Total number of reports that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of reports. #[serde(rename = "reports")] + #[serde(default = "default_reports")] pub reports: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_reports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ReportList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/resource_token.rs b/src/models/resource_token.rs index 2108383..4efceee 100644 --- a/src/models/resource_token.rs +++ b/src/models/resource_token.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct ResourceToken { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// JWT encoded string. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl ResourceToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/resource_token_list.rs b/src/models/resource_token_list.rs index af45953..de499c1 100644 --- a/src/models/resource_token_list.rs +++ b/src/models/resource_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ResourceTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ResourceTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/row.rs b/src/models/row.rs index 6c50624..308b438 100644 --- a/src/models/row.rs +++ b/src/models/row.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Row { /// Row ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Row sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Table ID. #[serde(rename = "$tableId")] + #[serde(default = "default_table_id")] pub table_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Row creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Row update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Row permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_table_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Row { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/row_list.rs b/src/models/row_list.rs index ff8047e..1ec0e23 100644 --- a/src/models/row_list.rs +++ b/src/models/row_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RowList { /// Total number of rows that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rows. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RowList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/runtime.rs b/src/models/runtime.rs index 71b88a9..d053cb1 100644 --- a/src/models/runtime.rs +++ b/src/models/runtime.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct Runtime { /// Runtime ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Parent runtime key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Runtime Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Runtime version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Base Docker image used to build the runtime. #[serde(rename = "base")] + #[serde(default = "default_base")] pub base: String, /// Image name of Docker Hub. #[serde(rename = "image")] + #[serde(default = "default_image")] pub image: String, /// Name of the logo image. #[serde(rename = "logo")] + #[serde(default = "default_logo")] pub logo: String, /// List of supported architectures. #[serde(rename = "supports")] + #[serde(default = "default_supports")] pub supports: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_base() -> String { + "".to_string() +} + +fn default_image() -> String { + "".to_string() +} + +fn default_logo() -> String { + "".to_string() +} + +fn default_supports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Runtime { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/runtime_list.rs b/src/models/runtime_list.rs index de7e84b..b45492d 100644 --- a/src/models/runtime_list.rs +++ b/src/models/runtime_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RuntimeList { /// Total number of runtimes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of runtimes. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RuntimeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/session.rs b/src/models/session.rs index 228fc31..3a775e0 100644 --- a/src/models/session.rs +++ b/src/models/session.rs @@ -8,97 +8,242 @@ use serde::{Deserialize, Serialize}; pub struct Session { /// Session ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Session update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Session expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Session Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Session Provider User ID. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Session Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Session Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// IP in use when the session was created. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Operating system code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). #[serde(rename = "osCode")] + #[serde(default = "default_os_code")] pub os_code: String, /// Operating system name. #[serde(rename = "osName")] + #[serde(default = "default_os_name")] pub os_name: String, /// Operating system version. #[serde(rename = "osVersion")] + #[serde(default = "default_os_version")] pub os_version: String, /// Client type. #[serde(rename = "clientType")] + #[serde(default = "default_client_type")] pub client_type: String, /// Client code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). #[serde(rename = "clientCode")] + #[serde(default = "default_client_code")] pub client_code: String, /// Client name. #[serde(rename = "clientName")] + #[serde(default = "default_client_name")] pub client_name: String, /// Client version. #[serde(rename = "clientVersion")] + #[serde(default = "default_client_version")] pub client_version: String, /// Client engine name. #[serde(rename = "clientEngine")] + #[serde(default = "default_client_engine")] pub client_engine: String, /// Client engine name. #[serde(rename = "clientEngineVersion")] + #[serde(default = "default_client_engine_version")] pub client_engine_version: String, /// Device name. #[serde(rename = "deviceName")] + #[serde(default = "default_device_name")] pub device_name: String, /// Device brand name. #[serde(rename = "deviceBrand")] + #[serde(default = "default_device_brand")] pub device_brand: String, /// Device model name. #[serde(rename = "deviceModel")] + #[serde(default = "default_device_model")] pub device_model: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, /// Returns true if this the current user session. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: bool, /// Returns a list of active session factors. #[serde(rename = "factors")] + #[serde(default = "default_factors")] pub factors: Vec, /// Secret used to authenticate the user. Only included if the request was made /// with an API key #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent date in ISO 8601 format when the session successfully passed /// MFA challenge. #[serde(rename = "mfaUpdatedAt")] + #[serde(default = "default_mfa_updated_at")] pub mfa_updated_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_os_code() -> String { + "".to_string() +} + +fn default_os_name() -> String { + "".to_string() +} + +fn default_os_version() -> String { + "".to_string() +} + +fn default_client_type() -> String { + "".to_string() +} + +fn default_client_code() -> String { + "".to_string() +} + +fn default_client_name() -> String { + "".to_string() +} + +fn default_client_version() -> String { + "".to_string() +} + +fn default_client_engine() -> String { + "".to_string() +} + +fn default_client_engine_version() -> String { + "".to_string() +} + +fn default_device_name() -> String { + "".to_string() +} + +fn default_device_brand() -> String { + "".to_string() +} + +fn default_device_model() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + +fn default_current() -> bool { + false +} + +fn default_factors() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_mfa_updated_at() -> String { + "".to_string() +} + impl Session { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/session_list.rs b/src/models/session_list.rs index 8e912c5..f74e7d3 100644 --- a/src/models/session_list.rs +++ b/src/models/session_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SessionList { /// Total number of sessions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sessions. #[serde(rename = "sessions")] + #[serde(default = "default_sessions")] pub sessions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sessions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SessionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/site.rs b/src/models/site.rs index 4cb6f80..a1f7723 100644 --- a/src/models/site.rs +++ b/src/models/site.rs @@ -8,112 +8,145 @@ use serde::{Deserialize, Serialize}; pub struct Site { /// Site ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Site creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Site update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Site name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Site enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the site deployed with the latest configuration? This is set to false if /// you've changed an environment variables, entrypoint, commands, or other /// settings that needs redeploy to be applied. When the value is false, /// redeploy the site to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, request logs will exclude logs and errors, and site /// responses will be slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Site framework. #[serde(rename = "framework")] + #[serde(default = "default_framework")] pub framework: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Site's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Screenshot of active deployment with light theme preference file ID. #[serde(rename = "deploymentScreenshotLight")] + #[serde(default = "default_deployment_screenshot_light")] pub deployment_screenshot_light: String, /// Screenshot of active deployment with dark theme preference file ID. #[serde(rename = "deploymentScreenshotDark")] + #[serde(default = "default_deployment_screenshot_dark")] pub deployment_screenshot_dark: String, /// Site's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Site variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Site request timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The install command used to install the site dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// The build command used to build the site. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Custom command to use when starting site runtime. #[serde(rename = "startCommand")] + #[serde(default = "default_start_command")] pub start_command: String, /// The directory where the site build output is located. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Site VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to site in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for SSR executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, /// Site build runtime. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// Site framework adapter. #[serde(rename = "adapter")] @@ -124,6 +157,138 @@ pub struct Site { pub fallback_file: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_framework() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_deployment_screenshot_light() -> String { + "".to_string() +} + +fn default_deployment_screenshot_dark() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_start_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + impl Site { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/site_list.rs b/src/models/site_list.rs index 1525368..ac1e2eb 100644 --- a/src/models/site_list.rs +++ b/src/models/site_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SiteList { /// Total number of sites that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sites. #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sites() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SiteList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/specification.rs b/src/models/specification.rs index 1cbb8a2..006eaf5 100644 --- a/src/models/specification.rs +++ b/src/models/specification.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Specification { /// Memory size in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Number of CPUs. #[serde(rename = "cpus")] + #[serde(default = "default_cpus")] pub cpus: f64, /// Is size enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Size slug. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, } +fn default_memory() -> i64 { + 0 +} + +fn default_cpus() -> f64 { + 0.0 +} + +fn default_enabled() -> bool { + false +} + +fn default_slug() -> String { + "".to_string() +} + impl Specification { /// Get memory pub fn memory(&self) -> &i64 { diff --git a/src/models/specification_list.rs b/src/models/specification_list.rs index de28440..887dc11 100644 --- a/src/models/specification_list.rs +++ b/src/models/specification_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SpecificationList { /// Total number of specifications that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SpecificationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/subscriber.rs b/src/models/subscriber.rs index 00b5d42..ed5a3b1 100644 --- a/src/models/subscriber.rs +++ b/src/models/subscriber.rs @@ -8,34 +8,74 @@ use serde::{Deserialize, Serialize}; pub struct Subscriber { /// Subscriber ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Subscriber creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Subscriber update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target ID. #[serde(rename = "targetId")] + #[serde(default = "default_target_id")] pub target_id: String, /// Target. #[serde(rename = "target")] pub target: crate::models::Target, /// Topic ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User Name. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// Topic ID. #[serde(rename = "topicId")] + #[serde(default = "default_topic_id")] pub topic_id: String, /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_target_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_topic_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + impl Subscriber { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/subscriber_list.rs b/src/models/subscriber_list.rs index 045c977..64636fe 100644 --- a/src/models/subscriber_list.rs +++ b/src/models/subscriber_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SubscriberList { /// Total number of subscribers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of subscribers. #[serde(rename = "subscribers")] + #[serde(default = "default_subscribers")] pub subscribers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_subscribers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SubscriberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/table.rs b/src/models/table.rs index 82cb1f0..1c33993 100644 --- a/src/models/table.rs +++ b/src/models/table.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Table { /// Table ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Table creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Table update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Table permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Table name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is /// inaccessible to users, but remains accessible to Server SDKs using API /// keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether row-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "rowSecurity")] + #[serde(default = "default_row_security")] pub row_security: bool, /// Table columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Table indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum row size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used row size in bytes based on defined columns. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_row_security() -> bool { + false +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Table { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/table_list.rs b/src/models/table_list.rs index 73748c1..53c23be 100644 --- a/src/models/table_list.rs +++ b/src/models/table_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TableList { /// Total number of tables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tables. #[serde(rename = "tables")] + #[serde(default = "default_tables")] pub tables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/target.rs b/src/models/target.rs index 79d2dc8..7bec4f4 100644 --- a/src/models/target.rs +++ b/src/models/target.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Target { /// Target ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Target creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Target update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Provider ID. #[serde(rename = "providerId")] @@ -28,15 +33,50 @@ pub struct Target { /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// The target identifier. #[serde(rename = "identifier")] + #[serde(default = "default_identifier")] pub identifier: String, /// Is the target expired. #[serde(rename = "expired")] + #[serde(default = "default_expired")] pub expired: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_identifier() -> String { + "".to_string() +} + +fn default_expired() -> bool { + false +} + impl Target { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/target_list.rs b/src/models/target_list.rs index a3edee5..0c7f169 100644 --- a/src/models/target_list.rs +++ b/src/models/target_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TargetList { /// Total number of targets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of targets. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TargetList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/team.rs b/src/models/team.rs index b951756..7da273c 100644 --- a/src/models/team.rs +++ b/src/models/team.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Team { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] pub prefs: crate::models::Preferences, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl Team { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/team_list.rs b/src/models/team_list.rs index d1df58e..f128b40 100644 --- a/src/models/team_list.rs +++ b/src/models/team_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TeamList { /// Total number of teams that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of teams. #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_teams() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TeamList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/token.rs b/src/models/token.rs index 89f96f4..903214a 100644 --- a/src/models/token.rs +++ b/src/models/token.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct Token { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. This will return an empty string unless the response is /// returned using an API key or as part of a webhook payload. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl Token { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/token_secret.rs b/src/models/token_secret.rs index 442416e..de2563e 100644 --- a/src/models/token_secret.rs +++ b/src/models/token_secret.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct TokenSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. Exchange it for a session with the create session /// endpoint. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl TokenSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic.rs b/src/models/topic.rs index 976d41b..ea701c4 100644 --- a/src/models/topic.rs +++ b/src/models/topic.rs @@ -8,39 +8,81 @@ use serde::{Deserialize, Serialize}; pub struct Topic { /// Topic ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Topic creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Topic update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name of the topic. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total count of email subscribers subscribed to the topic. #[serde(rename = "emailTotal")] + #[serde(default = "default_email_total")] pub email_total: i64, /// Total count of SMS subscribers subscribed to the topic. #[serde(rename = "smsTotal")] + #[serde(default = "default_sms_total")] pub sms_total: i64, /// Total count of push subscribers subscribed to the topic. #[serde(rename = "pushTotal")] + #[serde(default = "default_push_total")] pub push_total: i64, /// Subscribe permissions. #[serde(rename = "subscribe")] + #[serde(default = "default_subscribe")] pub subscribe: Vec, /// MQTT QoS for delivery on this topic. Null lets the subscriber choose their /// level. #[serde(rename = "qos")] #[serde(skip_serializing_if = "Option::is_none")] pub qos: Option, - /// Message retention in seconds for offline delivery. + /// Message retention in seconds for offline delivery. Null inherits the lowest + /// expiry of the project's enabled Appwrite providers, or the 7-day ledger + /// window if none sets one. #[serde(rename = "expiry")] #[serde(skip_serializing_if = "Option::is_none")] pub expiry: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_email_total() -> i64 { + 0 +} + +fn default_sms_total() -> i64 { + 0 +} + +fn default_push_total() -> i64 { + 0 +} + +fn default_subscribe() -> Vec { + serde_json::from_value(serde_json::json!(["users"])).unwrap() +} + impl Topic { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic_list.rs b/src/models/topic_list.rs index 824d84b..b7e128d 100644 --- a/src/models/topic_list.rs +++ b/src/models/topic_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TopicList { /// Total number of topics that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of topics. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TopicList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/transaction.rs b/src/models/transaction.rs index bb2272a..e034fe3 100644 --- a/src/models/transaction.rs +++ b/src/models/transaction.rs @@ -8,25 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct Transaction { /// Transaction ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Transaction creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Transaction update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Current status of the transaction. One of: pending, committing, committed, /// rolled_back, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of operations in the transaction. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: i64, /// Expiration time in ISO 8601 format. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_operations() -> i64 { + 0 +} + +fn default_expires_at() -> String { + "".to_string() +} + impl Transaction { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/transaction_list.rs b/src/models/transaction_list.rs index 29cab9e..6ebd9a0 100644 --- a/src/models/transaction_list.rs +++ b/src/models/transaction_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TransactionList { /// Total number of transactions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of transactions. #[serde(rename = "transactions")] + #[serde(default = "default_transactions")] pub transactions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_transactions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TransactionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/usage_billing_plan.rs b/src/models/usage_billing_plan.rs index ab2c459..ead81be 100644 --- a/src/models/usage_billing_plan.rs +++ b/src/models/usage_billing_plan.rs @@ -8,36 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct UsageBillingPlan { /// Bandwidth additional resources #[serde(rename = "bandwidth")] - pub bandwidth: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub bandwidth: Option, /// Executions additional resources #[serde(rename = "executions")] - pub executions: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub executions: Option, /// Member additional resources #[serde(rename = "member")] #[serde(skip_serializing_if = "Option::is_none")] pub member: Option, /// Realtime additional resources #[serde(rename = "realtime")] - pub realtime: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime: Option, /// Realtime messages additional resources #[serde(rename = "realtimeMessages")] - pub realtime_messages: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime_messages: Option, /// Realtime bandwidth additional resources #[serde(rename = "realtimeBandwidth")] #[serde(skip_serializing_if = "Option::is_none")] pub realtime_bandwidth: Option, /// Storage additional resources #[serde(rename = "storage")] - pub storage: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub storage: Option, /// User additional resources #[serde(rename = "users")] - pub users: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub users: Option, /// GBHour additional resources #[serde(rename = "GBHours")] - pub gb_hours: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub gb_hours: Option, /// Image transformation additional resources #[serde(rename = "imageTransformations")] - pub image_transformations: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub image_transformations: Option, /// Credits additional resources #[serde(rename = "credits")] #[serde(skip_serializing_if = "Option::is_none")] @@ -45,14 +53,26 @@ pub struct UsageBillingPlan { } impl UsageBillingPlan { + /// Set bandwidth + pub fn set_bandwidth(mut self, bandwidth: crate::models::AdditionalResource) -> Self { + self.bandwidth = Some(bandwidth); + self + } + /// Get bandwidth - pub fn bandwidth(&self) -> &crate::models::AdditionalResource { - &self.bandwidth + pub fn bandwidth(&self) -> Option<&crate::models::AdditionalResource> { + self.bandwidth.as_ref() + } + + /// Set executions + pub fn set_executions(mut self, executions: crate::models::AdditionalResource) -> Self { + self.executions = Some(executions); + self } /// Get executions - pub fn executions(&self) -> &crate::models::AdditionalResource { - &self.executions + pub fn executions(&self) -> Option<&crate::models::AdditionalResource> { + self.executions.as_ref() } /// Set member @@ -66,14 +86,29 @@ impl UsageBillingPlan { self.member.as_ref() } + /// Set realtime + pub fn set_realtime(mut self, realtime: crate::models::AdditionalResource) -> Self { + self.realtime = Some(realtime); + self + } + /// Get realtime - pub fn realtime(&self) -> &crate::models::AdditionalResource { - &self.realtime + pub fn realtime(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime.as_ref() + } + + /// Set realtime_messages + pub fn set_realtime_messages( + mut self, + realtime_messages: crate::models::AdditionalResource, + ) -> Self { + self.realtime_messages = Some(realtime_messages); + self } /// Get realtime_messages - pub fn realtime_messages(&self) -> &crate::models::AdditionalResource { - &self.realtime_messages + pub fn realtime_messages(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime_messages.as_ref() } /// Set realtime_bandwidth @@ -90,24 +125,51 @@ impl UsageBillingPlan { self.realtime_bandwidth.as_ref() } + /// Set storage + pub fn set_storage(mut self, storage: crate::models::AdditionalResource) -> Self { + self.storage = Some(storage); + self + } + /// Get storage - pub fn storage(&self) -> &crate::models::AdditionalResource { - &self.storage + pub fn storage(&self) -> Option<&crate::models::AdditionalResource> { + self.storage.as_ref() + } + + /// Set users + pub fn set_users(mut self, users: crate::models::AdditionalResource) -> Self { + self.users = Some(users); + self } /// Get users - pub fn users(&self) -> &crate::models::AdditionalResource { - &self.users + pub fn users(&self) -> Option<&crate::models::AdditionalResource> { + self.users.as_ref() + } + + /// Set gb_hours + pub fn set_gb_hours(mut self, gb_hours: crate::models::AdditionalResource) -> Self { + self.gb_hours = Some(gb_hours); + self } /// Get gb_hours - pub fn gb_hours(&self) -> &crate::models::AdditionalResource { - &self.gb_hours + pub fn gb_hours(&self) -> Option<&crate::models::AdditionalResource> { + self.gb_hours.as_ref() + } + + /// Set image_transformations + pub fn set_image_transformations( + mut self, + image_transformations: crate::models::AdditionalResource, + ) -> Self { + self.image_transformations = Some(image_transformations); + self } /// Get image_transformations - pub fn image_transformations(&self) -> &crate::models::AdditionalResource { - &self.image_transformations + pub fn image_transformations(&self) -> Option<&crate::models::AdditionalResource> { + self.image_transformations.as_ref() } /// Set credits @@ -129,14 +191,6 @@ mod tests { #[test] fn test_usage_billing_plan_creation() { let _model = ::default(); - let _ = _model.bandwidth(); - let _ = _model.executions(); - let _ = _model.realtime(); - let _ = _model.realtime_messages(); - let _ = _model.storage(); - let _ = _model.users(); - let _ = _model.gb_hours(); - let _ = _model.image_transformations(); } #[test] diff --git a/src/models/user.rs b/src/models/user.rs index d6e6d2e..9bcaa78 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct User { /// User ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// User creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Hashed user password. #[serde(rename = "password")] @@ -32,24 +36,31 @@ pub struct User { pub hash_options: Option, /// User registration date in ISO 8601 format. #[serde(rename = "registration")] + #[serde(default = "default_registration")] pub registration: String, /// User status. Pass `true` for enabled and `false` for disabled. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: bool, /// Labels for the user. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Password update time in ISO 8601 format. #[serde(rename = "passwordUpdate")] + #[serde(default = "default_password_update")] pub password_update: String, /// User email address. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: String, /// User phone number in E.164 format. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: String, /// Email verification status. #[serde(rename = "emailVerification")] + #[serde(default = "default_email_verification")] pub email_verification: bool, /// Canonical form of the user email address. #[serde(rename = "emailCanonical")] @@ -78,9 +89,11 @@ pub struct User { pub password_pwned: Option, /// Phone verification status. #[serde(rename = "phoneVerification")] + #[serde(default = "default_phone_verification")] pub phone_verification: bool, /// Multi factor authentication status. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// User preferences as a key-value object #[serde(rename = "prefs")] @@ -88,10 +101,12 @@ pub struct User { /// A user-owned message receiver. A single user may have multiple e.g. emails, /// phones, and a browser. Each target is registered with a single provider. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// Whether the user can impersonate other users. #[serde(rename = "impersonator")] @@ -106,6 +121,66 @@ pub struct User { pub impersonator_user_id: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_registration() -> String { + "".to_string() +} + +fn default_status() -> bool { + true +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_password_update() -> String { + "".to_string() +} + +fn default_email() -> String { + "".to_string() +} + +fn default_phone() -> String { + "".to_string() +} + +fn default_email_verification() -> bool { + false +} + +fn default_phone_verification() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl User { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/user_list.rs b/src/models/user_list.rs index a6e27f4..16c8f64 100644 --- a/src/models/user_list.rs +++ b/src/models/user_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct UserList { /// Total number of users that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of users. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl UserList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/variable.rs b/src/models/variable.rs index cadb289..b27a858 100644 --- a/src/models/variable.rs +++ b/src/models/variable.rs @@ -8,33 +8,73 @@ use serde::{Deserialize, Serialize}; pub struct Variable { /// Variable ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Variable key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Variable value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Variable secret flag. Secret variables can only be updated or deleted, but /// never read. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: bool, /// Service to which the variable belongs. Possible values are "project", /// "function" #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of resource to which the variable belongs. If resourceType is "project", /// it is empty. If resourceType is "function", it is ID of the function. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + +fn default_secret() -> bool { + false +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + impl Variable { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/variable_list.rs b/src/models/variable_list.rs index 9720690..3c3a8bf 100644 --- a/src/models/variable_list.rs +++ b/src/models/variable_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VariableList { /// Total number of variables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of variables. #[serde(rename = "variables")] + #[serde(default = "default_variables")] pub variables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_variables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VariableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/vectorsdb_collection.rs b/src/models/vectorsdb_collection.rs index f352907..38e0c83 100644 --- a/src/models/vectorsdb_collection.rs +++ b/src/models/vectorsdb_collection.rs @@ -8,49 +8,114 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, /// Embedding dimension. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + +fn default_dimension() -> i64 { + 0 +} + impl VectorsdbCollection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/vectorsdb_collection_list.rs b/src/models/vectorsdb_collection_list.rs index 719dfca..09c5647 100644 --- a/src/models/vectorsdb_collection_list.rs +++ b/src/models/vectorsdb_collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VectorsdbCollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/webhook.rs b/src/models/webhook.rs index 5e398a3..3875de3 100644 --- a/src/models/webhook.rs +++ b/src/models/webhook.rs @@ -8,46 +8,111 @@ use serde::{Deserialize, Serialize}; pub struct Webhook { /// Webhook ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Webhook creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Webhook update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Webhook name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Webhook URL endpoint. #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Webhook trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Indicates if SSL / TLS certificate verification is enabled. #[serde(rename = "tls")] + #[serde(default = "default_tls")] pub tls: bool, /// HTTP basic authentication username. #[serde(rename = "authUsername")] + #[serde(default = "default_auth_username")] pub auth_username: String, - /// HTTP basic authentication password. + /// HTTP basic authentication password. Write-only: always returned empty. #[serde(rename = "authPassword")] + #[serde(default = "default_auth_password")] pub auth_password: String, /// Signature key which can be used to validate incoming webhook payloads. Only /// returned on creation and secret rotation. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Indicates if this webhook is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Webhook error logs from the most recent failure. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Number of consecutive failed webhook attempts. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tls() -> bool { + true +} + +fn default_auth_username() -> String { + "".to_string() +} + +fn default_auth_password() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + impl Webhook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/webhook_list.rs b/src/models/webhook_list.rs index 29d04f7..d9602c4 100644 --- a/src/models/webhook_list.rs +++ b/src/models/webhook_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct WebhookList { /// Total number of webhooks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of webhooks. #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_webhooks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl WebhookList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/services/account.rs b/src/services/account.rs index 9313048..1db7444 100644 --- a/src/services/account.rs +++ b/src/services/account.rs @@ -105,9 +105,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -117,18 +127,25 @@ impl Account { /// Delete an OAuth2 consent by its unique ID. All token families issued under /// the consent are revoked, and the app must ask for consent again to regain /// access. - pub async fn delete_consent( - &self, - consent_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_consent(&self, consent_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -157,9 +174,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -177,10 +204,30 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -194,16 +241,36 @@ impl Account { &self, consent_id: impl Into, token_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -270,43 +337,27 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/account/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } - /// 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. - pub async fn list_logs( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/account/logs".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - /// Enable or disable MFA on an account. pub async fn update_mfa(&self, mfa: bool) -> crate::error::Result { let mut params = HashMap::new(); @@ -375,6 +426,7 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/mfa/authenticators/{type}" .to_string() @@ -928,6 +980,7 @@ impl Account { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/sessions".to_string(); @@ -958,6 +1011,9 @@ impl Account { /// 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 @@ -1137,9 +1193,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1158,9 +1224,19 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1176,10 +1252,21 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1289,6 +1376,10 @@ impl Account { /// 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). diff --git a/src/services/activities.rs b/src/services/activities.rs index c9017d0..b482235 100644 --- a/src/services/activities.rs +++ b/src/services/activities.rs @@ -55,9 +55,19 @@ impl Activities { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let event_id = event_id.into(); + if event_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"eventId\"", + None, + String::new(), + )); + } + let path = "/activities/events/{eventId}" .to_string() - .replace("{eventId}", &event_id.into().to_string()); + .replace("{eventId}", &event_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/advisor.rs b/src/services/advisor.rs index 084c5f2..ae581e6 100644 --- a/src/services/advisor.rs +++ b/src/services/advisor.rs @@ -61,9 +61,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -76,10 +86,21 @@ impl Advisor { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -107,9 +128,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -126,10 +157,30 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + + let insight_id = insight_id.into(); + if insight_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"insightId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights/{insightId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()) - .replace("{insightId}", &insight_id.into().to_string()); + .replace("{reportId}", &report_id) + .replace("{insightId}", &insight_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/apps.rs b/src/services/apps.rs index 46c3c4b..8ed7d09 100644 --- a/src/services/apps.rs +++ b/src/services/apps.rs @@ -189,9 +189,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -301,9 +309,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -311,18 +327,23 @@ impl Apps { } /// Delete an application by its unique ID. - pub async fn delete( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -351,9 +372,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -372,10 +403,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -389,16 +440,36 @@ impl Apps { &self, app_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -423,10 +494,30 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -453,9 +544,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -474,9 +573,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -493,10 +600,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,16 +635,36 @@ impl Apps { &self, app_id: impl Into, key_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -544,9 +691,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/labels" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -573,9 +730,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -592,9 +759,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -611,10 +788,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -626,16 +823,36 @@ impl Apps { &self, app_id: impl Into, secret_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -654,9 +871,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/team" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/team".to_string().replace("{appId}", &app_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -664,18 +889,25 @@ impl Apps { } /// Revoke all tokens for an application by its unique ID. - pub async fn delete_tokens( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_tokens(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/avatars.rs b/src/services/avatars.rs index 60c40ab..6a529a4 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -236,9 +236,9 @@ impl Avatars { } /// 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, @@ -483,27 +483,6 @@ impl crate::services::Service for Avatars { mod tests { use super::*; - #[tokio::test] - async fn test_update_photo_sends_one_request_whatever_the_chunk_size() { - use wiremock::matchers::{method, path}; - use wiremock::{Mock, MockServer, ResponseTemplate}; - - let server = MockServer::start().await; - Mock::given(method("PUT")) - .and(path("/avatars/photo")) - .respond_with(ResponseTemplate::new(500)) - .mount(&server) - .await; - - let client = Client::new().set_endpoint(server.uri()).set_chunk_size(1); - let file = InputFile::from_bytes(vec![0u8; 10], "photo.png", Some("image/png")); - let _ = Avatars::new(&client).update_photo(file).await; - - let requests = server.received_requests().await.unwrap(); - assert_eq!(requests.len(), 1); - assert!(requests[0].headers.get("content-range").is_none()); - } - #[test] fn test_avatars_creation() { let client = Client::new(); diff --git a/src/services/backups.rs b/src/services/backups.rs index 3379cb7..20fb617 100644 --- a/src/services/backups.rs +++ b/src/services/backups.rs @@ -77,9 +77,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -87,18 +97,25 @@ impl Backups { } /// Delete an existing archive for a project. - pub async fn delete_archive( - &self, - archive_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_archive(&self, archive_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -173,9 +190,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -208,9 +235,19 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -218,18 +255,25 @@ impl Backups { } /// Delete a policy using it's ID. - pub async fn delete_policy( - &self, - policy_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_policy(&self, policy_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -325,9 +369,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/backups/restorations/{restorationId}" .to_string() - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/databases.rs b/src/services/databases.rs index 6d30c67..c9f3774 100644 --- a/src/services/databases.rs +++ b/src/services/databases.rs @@ -134,9 +134,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -178,10 +198,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -221,9 +262,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -248,9 +299,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -263,10 +324,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -298,9 +370,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -348,9 +430,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -368,10 +460,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -413,10 +525,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -433,11 +565,32 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -465,10 +618,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,10 +681,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -550,11 +743,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -584,10 +807,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -617,11 +860,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -651,10 +924,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -684,11 +977,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -718,10 +1041,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -751,11 +1094,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -795,10 +1168,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -837,11 +1230,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -881,10 +1304,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -923,11 +1366,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -967,10 +1440,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1502,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1043,10 +1566,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1076,11 +1619,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1106,10 +1679,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1139,11 +1732,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1178,10 +1801,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1211,11 +1854,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1250,10 +1923,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1283,11 +1976,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1313,10 +2036,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1346,11 +2089,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1376,10 +2149,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1409,11 +2202,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1456,10 +2279,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1487,12 +2330,42 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1529,10 +2402,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1567,11 +2460,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1606,10 +2529,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1639,11 +2582,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1673,10 +2646,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1706,11 +2699,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1747,10 +2770,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1785,11 +2828,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1807,11 +2880,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1828,12 +2931,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1870,10 +3004,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1909,10 +3063,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1939,10 +3113,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1969,10 +3163,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2007,10 +3221,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2040,10 +3274,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2073,11 +3327,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2114,11 +3398,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2153,11 +3467,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2178,12 +3522,43 @@ impl Databases { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2216,13 +3591,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2255,13 +3670,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2289,10 +3744,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2301,7 +3776,9 @@ impl Databases { /// Creates an index on the attributes listed. Your index should include all /// the attributes you will query in a single request. - /// Attributes can be `key`, `fulltext`, and `unique`. + /// Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + /// `trigram` is only available on PostgreSQL and lets `contains`, + /// `startsWith`, and `endsWith` queries on string attributes use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2333,10 +3810,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2354,11 +3851,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2375,12 +3902,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/documents_db.rs b/src/services/documents_db.rs index 6f761f7..ca88c34 100644 --- a/src/services/documents_db.rs +++ b/src/services/documents_db.rs @@ -86,8 +86,8 @@ impl DocumentsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -381,9 +463,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +493,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -444,10 +556,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -464,11 +596,32 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -505,10 +658,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -544,10 +717,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -574,10 +767,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -604,10 +817,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -642,10 +875,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -675,10 +928,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -708,11 +981,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -749,11 +1052,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -788,11 +1121,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -813,12 +1176,43 @@ impl DocumentsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -851,13 +1245,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -890,13 +1324,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -924,10 +1398,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -968,10 +1462,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -989,11 +1503,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1010,12 +1554,43 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1044,9 +1619,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1077,9 +1662,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1096,9 +1691,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1116,9 +1721,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/functions.rs b/src/services/functions.rs index 3dd0131..be83cfa 100644 --- a/src/services/functions.rs +++ b/src/services/functions.rs @@ -224,9 +224,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -342,9 +352,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -356,10 +376,21 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -379,9 +410,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployment" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -413,9 +454,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -455,12 +506,30 @@ impl Functions { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -484,9 +553,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/duplicate" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -522,9 +601,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/template" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -551,9 +640,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/vcs" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -570,10 +669,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -589,11 +708,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -620,10 +760,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/download" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -645,10 +805,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/status" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -676,9 +856,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -723,9 +913,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -742,10 +942,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -761,11 +981,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -792,9 +1033,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -822,9 +1073,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -841,10 +1102,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -874,10 +1155,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -893,11 +1194,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/messaging.rs b/src/services/messaging.rs index 71dc9c2..596c87a 100644 --- a/src/services/messaging.rs +++ b/src/services/messaging.rs @@ -222,9 +222,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/email/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -433,9 +443,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/push/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -538,9 +558,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/sms/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -556,9 +586,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -571,10 +611,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -601,9 +652,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}/targets" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -724,9 +785,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/apns/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -860,9 +931,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/fcm/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -969,9 +1050,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/mailgun/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1044,9 +1135,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/msg91/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1137,9 +1238,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/resend/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1230,9 +1341,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/sendgrid/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1339,9 +1460,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/ses/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1478,9 +1609,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/smtp/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1553,9 +1694,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/telesign/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1628,9 +1779,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/textmagic/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1703,9 +1864,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/twilio/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1778,9 +1949,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/vonage/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1796,9 +1977,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1813,10 +2004,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1897,9 +2099,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1935,9 +2147,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1949,10 +2171,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1983,9 +2216,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2006,9 +2249,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2025,10 +2278,30 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2044,11 +2317,32 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/mongo.rs b/src/services/mongo.rs index 9b57b1e..1cd671e 100644 --- a/src/services/mongo.rs +++ b/src/services/mongo.rs @@ -121,8 +121,8 @@ impl Mongo { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mongo { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mongo { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mongo { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -682,9 +909,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -707,9 +944,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -735,9 +982,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -768,9 +1025,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -787,9 +1054,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -806,9 +1083,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -841,9 +1128,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -879,9 +1176,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -899,10 +1206,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -920,9 +1247,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -942,9 +1279,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/mysql.rs b/src/services/mysql.rs index 434f42b..092d103 100644 --- a/src/services/mysql.rs +++ b/src/services/mysql.rs @@ -121,8 +121,8 @@ impl Mysql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mysql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mysql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mysql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -688,9 +915,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -719,9 +956,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -744,9 +991,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -772,9 +1029,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -805,9 +1072,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -824,9 +1101,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -843,9 +1130,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -896,9 +1193,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -915,9 +1222,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -950,9 +1267,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -988,9 +1315,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1008,10 +1345,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1029,9 +1386,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1051,9 +1418,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/oauth2.rs b/src/services/oauth2.rs index 834934a..9691f1f 100644 --- a/src/services/oauth2.rs +++ b/src/services/oauth2.rs @@ -81,7 +81,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -120,7 +120,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -165,7 +168,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -204,7 +207,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -238,7 +244,7 @@ impl Oauth2 { client_id: Option<&str>, scope: Option<&str>, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -252,7 +258,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -318,6 +327,16 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let grant_id = grant_id.into(); + if grant_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"grantId\"", + None, + String::new(), + )); + } + let path = "/oauth2/{project_id}/grants/{grant_id}" .to_string() .replace( @@ -329,7 +348,7 @@ impl Oauth2 { .cloned() .unwrap_or_default(), ) - .replace("{grant_id}", &grant_id.into().to_string()); + .replace("{grant_id}", &grant_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -430,7 +449,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -462,7 +481,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -603,7 +625,7 @@ impl Oauth2 { client_secret: Option<&str>, code_verifier: Option<&str>, redirect_uri: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -630,7 +652,10 @@ impl Oauth2 { params.insert("redirect_uri".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); diff --git a/src/services/organization.rs b/src/services/organization.rs index 176b0f5..a574ade 100644 --- a/src/services/organization.rs +++ b/src/services/organization.rs @@ -60,6 +60,7 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/organization".to_string(); @@ -129,9 +130,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -155,9 +166,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -170,130 +191,25 @@ impl Organization { pub async fn delete_installation( &self, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}" - .to_string() - .replace("{installationId}", &installation_id.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a list of all API keys from the current organization. - pub async fn list_keys( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Create a new organization API key. - pub async fn create_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("keyId".to_string(), json!(key_id.into())); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::POST, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a key by its unique ID. This endpoint returns details about a specific - /// API key in your organization including its scopes. - pub async fn get_key( - &self, - key_id: impl Into, - ) -> crate::error::Result { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Update a key by its unique ID. Use this endpoint to update the name, - /// scopes, or expiration time of an API key. - pub async fn update_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Delete a key by its unique ID. Once deleted, the key can no longer be used - /// to authenticate API calls. - pub async fn delete_key(&self, key_id: impl Into) -> crate::error::Result<()> { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" + let path = "/organization/installations/{installationId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -382,9 +298,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -406,9 +332,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -425,10 +361,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -496,13 +443,25 @@ impl Organization { project_id: impl Into, ) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -518,9 +477,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } + let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -532,10 +501,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/postgresql.rs b/src/services/postgresql.rs index e736abe..10a50a2 100644 --- a/src/services/postgresql.rs +++ b/src/services/postgresql.rs @@ -121,8 +121,8 @@ impl Postgresql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Postgresql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Postgresql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Postgresql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -688,9 +915,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -706,9 +943,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -728,9 +975,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -749,10 +1006,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let extension_name = extension_name.into(); + if extension_name.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"extensionName\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions/{extensionName}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{extensionName}", &extension_name.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{extensionName}", &extension_name); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -781,9 +1058,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -806,9 +1093,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -834,9 +1131,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -867,9 +1174,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -886,9 +1203,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -905,9 +1232,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -958,9 +1295,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -977,9 +1324,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1012,9 +1369,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1050,9 +1417,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1070,10 +1447,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1091,9 +1488,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1113,9 +1520,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/presences.rs b/src/services/presences.rs index 2954c14..6b777c6 100644 --- a/src/services/presences.rs +++ b/src/services/presences.rs @@ -64,9 +64,19 @@ impl Presences { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -102,9 +112,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -148,9 +168,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -162,10 +192,21 @@ impl Presences { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/project.rs b/src/services/project.rs index 43c2af2..24f9252 100644 --- a/src/services/project.rs +++ b/src/services/project.rs @@ -27,11 +27,13 @@ impl Project { /// Get a project. pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -40,6 +42,7 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); @@ -266,9 +269,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -294,9 +307,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -309,10 +332,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -402,9 +436,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -424,9 +468,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -439,10 +493,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1253,8 +1318,8 @@ impl Project { &self, client_id: Option<&str>, client_secret: Option<&str>, - prompt: Option>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1263,12 +1328,12 @@ impl Project { if let Some(value) = client_secret { params.insert("clientSecret".to_string(), json!(value)); } - if let Some(value) = prompt { - params.insert("prompt".to_string(), json!(value)); - } if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } + if let Some(value) = prompt { + params.insert("prompt".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); @@ -2147,7 +2212,7 @@ impl Project { } /// 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. pub async fn update_android_platform( &self, platform_id: impl Into, @@ -2168,9 +2233,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/android/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2222,9 +2297,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/apple/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2270,9 +2355,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/linux/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2318,9 +2413,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/web/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2372,9 +2477,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/windows/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2391,9 +2506,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2409,10 +2534,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -3027,6 +3163,7 @@ impl Project { ); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project/smtp/tests".to_string(); @@ -3197,9 +3334,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -3228,9 +3375,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -3245,10 +3402,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/proxy.rs b/src/services/proxy.rs index 2507b73..ad548f3 100644 --- a/src/services/proxy.rs +++ b/src/services/proxy.rs @@ -29,6 +29,8 @@ impl Proxy { /// /// 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. pub async fn create_invalidation( &self, domain: impl Into, @@ -193,9 +195,19 @@ impl Proxy { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -207,10 +219,21 @@ impl Proxy { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -230,9 +253,19 @@ impl Proxy { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}/status" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/sites.rs b/src/services/sites.rs index 150a50d..99a6e87 100644 --- a/src/services/sites.rs +++ b/src/services/sites.rs @@ -217,9 +217,17 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +339,17 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -345,10 +361,19 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -368,9 +393,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployment" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -402,9 +437,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -443,12 +488,30 @@ impl Sites { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -468,9 +531,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/duplicate" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -506,9 +579,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/template" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -535,9 +618,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/vcs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -554,10 +647,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -573,11 +686,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -604,10 +738,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/download" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -629,10 +783,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/status" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -660,9 +834,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -679,10 +863,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -694,16 +898,36 @@ impl Sites { &self, site_id: impl Into, log_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -730,9 +954,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -760,9 +994,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -779,10 +1023,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -812,10 +1076,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -831,11 +1115,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/storage.rs b/src/services/storage.rs index 4736eaf..2f49674 100644 --- a/src/services/storage.rs +++ b/src/services/storage.rs @@ -127,9 +127,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -191,9 +201,19 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -205,10 +225,21 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -240,9 +271,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -293,12 +334,23 @@ impl Storage { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client - .file_upload( + .upload( + Method::POST, &path, Some(api_headers), params, @@ -320,10 +372,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -353,10 +425,30 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -373,11 +465,32 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -400,10 +513,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/download" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -473,10 +606,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/preview" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/view" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/tables_db.rs b/src/services/tables_db.rs index a9f0f21..1a3da92 100644 --- a/src/services/tables_db.rs +++ b/src/services/tables_db.rs @@ -92,8 +92,8 @@ impl TablesDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -163,9 +163,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -190,9 +200,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -207,10 +227,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -231,9 +262,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -250,9 +291,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -289,9 +340,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -304,10 +365,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -336,9 +408,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -355,9 +437,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -382,9 +474,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +503,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -417,16 +539,36 @@ impl TablesDB { &self, database_id: impl Into, migration_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -449,10 +591,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}/cutovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -483,9 +645,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -502,9 +674,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -522,9 +704,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -556,9 +748,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +808,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -626,10 +838,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -671,10 +903,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -691,11 +943,32 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -723,10 +996,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -766,10 +1059,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -808,11 +1121,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -842,10 +1185,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -875,11 +1238,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -909,10 +1302,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -942,11 +1355,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -976,10 +1419,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1472,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1053,10 +1546,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1095,11 +1608,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1139,10 +1682,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1181,11 +1744,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1225,10 +1818,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1267,11 +1880,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1301,10 +1944,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1334,11 +1997,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1364,10 +2057,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1397,11 +2110,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1436,10 +2179,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1469,11 +2232,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1508,10 +2301,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1541,11 +2354,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1571,10 +2414,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1604,11 +2467,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1634,10 +2527,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1667,11 +2580,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1711,16 +2654,98 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) .await } + /// Update relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + pub async fn update_relationship_column( + &self, + database_id: impl Into, + table_id: impl Into, + key: impl Into, + on_delete: Option, + new_key: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = on_delete { + params.insert("onDelete".to_string(), json!(value)); + } + if let Some(value) = new_key { + params.insert("newKey".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Create a string column. #[allow(clippy::too_many_arguments)] pub async fn create_string_column( @@ -1751,10 +2776,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1789,11 +2834,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1828,10 +2903,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1861,11 +2956,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1895,10 +3020,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1928,11 +3073,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1969,10 +3144,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2007,11 +3202,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2029,11 +3254,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2050,47 +3305,46 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" - .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } - /// Update relationship column. [Learn more about relationship - /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - pub async fn update_relationship_column( - &self, - database_id: impl Into, - table_id: impl Into, - key: impl Into, - on_delete: Option, - new_key: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = on_delete { - params.insert("onDelete".to_string(), json!(value)); + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); } - if let Some(value) = new_key { - params.insert("newKey".to_string(), json!(value)); + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship" + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client - .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } @@ -2115,10 +3369,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2127,7 +3401,9 @@ impl TablesDB { /// Creates an index on the columns listed. Your index should include all the /// columns you will query in a single request. - /// Type can be `key`, `fulltext`, or `unique`. + /// Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + /// is only available on PostgreSQL and lets `contains`, `startsWith`, and + /// `endsWith` queries on string columns use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2159,10 +3435,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2180,11 +3476,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2201,12 +3527,43 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2243,10 +3600,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2282,10 +3659,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2312,10 +3709,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2342,10 +3759,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2379,10 +3816,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2412,10 +3869,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2445,11 +3922,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2486,11 +3993,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2525,11 +4062,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2550,12 +4117,43 @@ impl TablesDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2588,12 +4186,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2626,12 +4264,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/teams.rs b/src/services/teams.rs index 5f55c5b..68d6978 100644 --- a/src/services/teams.rs +++ b/src/services/teams.rs @@ -93,9 +93,17 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -114,9 +122,17 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -129,10 +145,19 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -159,9 +184,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -187,9 +222,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -207,10 +252,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -235,10 +300,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -252,16 +337,36 @@ impl Teams { &self, team_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -294,9 +399,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -362,9 +477,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -383,10 +508,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -411,10 +556,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -432,11 +597,32 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -463,10 +649,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}/status" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -484,9 +690,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -507,9 +723,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) diff --git a/src/services/tokens.rs b/src/services/tokens.rs index 43b9063..d58c5cb 100644 --- a/src/services/tokens.rs +++ b/src/services/tokens.rs @@ -46,10 +46,30 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -72,10 +92,30 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -91,9 +131,19 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -115,9 +165,19 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -129,10 +189,21 @@ impl Tokens { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/users.rs b/src/services/users.rs index 7cd8e38..73b7d8b 100644 --- a/src/services/users.rs +++ b/src/services/users.rs @@ -184,10 +184,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/users/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -377,9 +388,17 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -396,10 +415,19 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -418,9 +446,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/email" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -431,7 +469,10 @@ impl Users { /// 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. pub async fn update_impersonator( &self, user_id: impl Into, @@ -443,9 +484,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/impersonator" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -472,9 +523,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/jwts" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -504,41 +565,22 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/labels" - .to_string() - .replace("{userId}", &user_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Get the user activity logs list by its unique ID. - pub async fn list_logs( - &self, - user_id: impl Into, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/logs" + let path = "/users/{userId}/labels" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) + .call(Method::PUT, &path, Some(api_headers), Some(params)) .await } @@ -566,9 +608,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/memberships" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -587,9 +639,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -605,10 +667,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/mfa/authenticators/{type}" .to_string() - .replace("{userId}", &user_id.into().to_string()) + .replace("{userId}", &user_id) .replace("{type}", &r#type.to_string()); self.client @@ -627,10 +700,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let challenge_id = challenge_id.into(); + if challenge_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"challengeId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/challenges/{challengeId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{challengeId}", &challenge_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{challengeId}", &challenge_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -646,9 +739,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/factors" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -667,9 +770,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -689,9 +802,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -711,9 +834,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -732,9 +865,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/name" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -917,9 +1060,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/password" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -938,9 +1091,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -956,9 +1119,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -979,9 +1152,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1001,9 +1184,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1025,9 +1218,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1039,10 +1242,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1058,11 +1272,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions/{sessionId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1082,9 +1317,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/status" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1111,9 +1356,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1144,9 +1399,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1163,10 +1428,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1196,10 +1481,30 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1215,11 +1520,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1247,9 +1573,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/tokens" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1268,9 +1604,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1289,9 +1635,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/vectors_db.rs b/src/services/vectors_db.rs index be3894b..a89bf38 100644 --- a/src/services/vectors_db.rs +++ b/src/services/vectors_db.rs @@ -86,8 +86,8 @@ impl VectorsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -375,9 +457,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -395,10 +487,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -438,10 +550,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -458,11 +590,32 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -538,10 +711,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -568,10 +761,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -598,10 +811,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -636,10 +869,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,10 +922,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -712,10 +985,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/query" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -745,11 +1038,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -786,11 +1109,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -825,11 +1178,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -850,12 +1233,43 @@ impl VectorsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -883,10 +1297,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -927,10 +1361,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -948,11 +1402,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -969,12 +1453,43 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1003,9 +1518,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1036,9 +1561,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1055,9 +1590,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1075,9 +1620,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/webhooks.rs b/src/services/webhooks.rs index 0e3e171..c53feda 100644 --- a/src/services/webhooks.rs +++ b/src/services/webhooks.rs @@ -112,9 +112,19 @@ impl Webhooks { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -176,10 +196,21 @@ impl Webhooks { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}/secret" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/topic.rs b/src/topic.rs new file mode 100644 index 0000000..e36d0fe --- /dev/null +++ b/src/topic.rs @@ -0,0 +1,251 @@ +//! Topic builder for Appwrite Push, level by level. +//! +//! ``` +//! use appwrite::topic; +//! +//! # fn main() -> Result<(), topic::TopicError> { +//! assert_eq!(topic::path(&["user", "123", "notification"])?.to_string(), "user/123/notification"); +//! assert_eq!(topic::path(&["user"])?.any().path(&["notification"])?.to_string(), "user/+/notification"); +//! assert_eq!(topic::path(&["org"])?.any().path(&["logs"])?.all().to_string(), "org/+/logs/#"); +//! # Ok(()) +//! # } +//! ``` +//! +//! `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`], which has no methods +//! to append further levels. + +use std::fmt; + +/// Error returned by [`path`] and [`Topic::path`] for invalid levels. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct TopicError { + message: String, +} + +impl TopicError { + fn new(message: impl Into) -> Self { + Self { + message: message.into(), + } + } + + /// The error message + pub fn message(&self) -> &str { + &self.message + } +} + +impl fmt::Display for TopicError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.message) + } +} + +impl std::error::Error for TopicError {} + +/// A topic being built. Start one with [`path`] or [`any`]. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Topic { + levels: Vec, +} + +/// A topic ended by `all()`: nothing can be appended after the `#` wildcard. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ResolvedTopic { + levels: Vec, +} + +/// Start a topic with the given levels, e.g. `topic::path(&["user", user_id])`. +pub fn path>(levels: &[S]) -> Result { + Ok(Topic { + levels: levels_of(levels)?, + }) +} + +/// Start a topic with a single-level wildcard (`+`). +pub fn any() -> Topic { + Topic { + levels: vec!["+".to_string()], + } +} + +/// The multi-level wildcard alone (`#`): matches every topic. +pub fn all() -> ResolvedTopic { + ResolvedTopic { + levels: vec!["#".to_string()], + } +} + +impl Topic { + /// Append the given levels. + pub fn path>(mut self, levels: &[S]) -> Result { + self.levels.extend(levels_of(levels)?); + Ok(self) + } + + /// Append a single-level wildcard (`+`): matches exactly one level. + pub fn any(mut self) -> Topic { + self.levels.push("+".to_string()); + self + } + + /// Append the multi-level wildcard (`#`) and end the topic. + pub fn all(mut self) -> ResolvedTopic { + self.levels.push("#".to_string()); + ResolvedTopic { + levels: self.levels, + } + } +} + +impl fmt::Display for Topic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.levels.join("/")) + } +} + +impl fmt::Display for ResolvedTopic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.levels.join("/")) + } +} + +/// Validate the levels passed to `path()`: a non-empty list of non-empty strings, none holding +/// the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). +fn levels_of>(levels: &[S]) -> Result, TopicError> { + if levels.is_empty() { + return Err(TopicError::new("path() needs at least one level")); + } + levels + .iter() + .enumerate() + .map(|(index, level)| { + let level = level.as_ref(); + if level.is_empty() { + return Err(TopicError::new(format!("empty level at index {}", index))); + } + if level.contains('/') { + let parts = level + .split('/') + .map(|part| format!("'{}'", part)) + .collect::>() + .join(", "); + return Err(TopicError::new(format!( + "\"{}\" contains \"/\", split it: path([{}])", + level, parts + ))); + } + if level == "+" { + return Err(TopicError::new("\"+\" is reserved, use any()")); + } + if level.contains('+') { + return Err(TopicError::new(format!( + "\"{}\" contains \"+\", use any() for wildcards", + level + ))); + } + if level == "#" { + return Err(TopicError::new("\"#\" is reserved, use all()")); + } + if level.contains('#') { + return Err(TopicError::new(format!( + "\"{}\" contains \"#\", use all() for wildcards", + level + ))); + } + Ok(level.to_string()) + }) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_paths() { + assert_eq!( + path(&["user", "123", "notification"]).unwrap().to_string(), + "user/123/notification" + ); + assert_eq!( + path(&["org", "42", "user", "123"]) + .unwrap() + .path(&["notification"]) + .unwrap() + .to_string(), + "org/42/user/123/notification" + ); + assert_eq!( + path(&[String::from("user"), String::from("123")]) + .unwrap() + .to_string(), + "user/123" + ); + } + + #[test] + fn test_any() { + assert_eq!( + path(&["user"]) + .unwrap() + .any() + .path(&["notification"]) + .unwrap() + .to_string(), + "user/+/notification" + ); + assert_eq!( + path(&["chat"]) + .unwrap() + .any() + .any() + .path(&["message"]) + .unwrap() + .to_string(), + "chat/+/+/message" + ); + } + + #[test] + fn test_all() { + assert_eq!( + path(&["org"]) + .unwrap() + .any() + .path(&["logs"]) + .unwrap() + .all() + .to_string(), + "org/+/logs/#" + ); + } + + #[test] + fn test_static_any_and_all() { + assert_eq!( + any().path(&["notification"]).unwrap().to_string(), + "+/notification" + ); + assert_eq!(any().to_string(), "+"); + assert_eq!(all().to_string(), "#"); + } + + #[test] + fn test_errors() { + let invalid: [&[&str]; 7] = [ + &[], + &["user", ""], + &["user/123"], + &["user", "+"], + &["user", "a+b"], + &["user", "#"], + &["user", "a#b"], + ]; + for levels in invalid { + assert!(path(levels).is_err(), "{:?}", levels); + assert!(any().path(levels).is_err(), "{:?}", levels); + } + } +} diff --git a/tests/tests.rs b/tests/tests.rs index 2821bc3..d47a3bf 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,11 +1,13 @@ use appwrite::{ Client, + enums::PresetQuality, id::ID, input_file::InputFile, operator::{self, Condition}, permission::Permission, query::Query, role::Role, + topic, services::*, }; use serde_json::json; @@ -112,12 +114,50 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re Err(e) => eprintln!("general.redirected => error {}", e), } + for (id, plain) in [("", "0"), ("0", "")] { + let error = general.validate_path(plain, Some(id)).await.unwrap_err(); + assert_eq!(error.code, 0); + println!("{}", error.message); + } + println!("{}", general.validate_path("0", Some("0")).await?.result); + println!("{}", general.validate_path("0", None).await?.result); + + let zone: String = Plaintext::new(&client).get_zone().await?; + println!("{}", zone); + println!("{}", general.get_mixed().await?.result); + let plaintext = Plaintext::new(&client); + let records = "www 3600 IN A 192.0.2.1"; + println!("{}", plaintext.import_zone(records, None).await?); + let zone_file = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", plaintext.import_zone(records, Some(zone_file)).await?); + + let message = "conversation without a required file"; + println!("{}", general.optional_upload(message, None, None).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), None).await?.result); + println!("{}", general.optional_upload(message, None, Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + test_general_upload(client, string_in_array).await?; test_large_upload(client, string_in_array).await?; + // A PUT upload has no chunked form, so it must go in one request even with tiny chunks. + let small_chunks = client.set_chunk_size(1024); + let profile = General::new(&small_chunks).upload_generic(InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?).await?; + println!("{}", profile.prefs().get::("result").unwrap_or_default()); // Extended General Responses test_general_download(client).await?; + let preset = general.get_preset(None).await?; + println!("preset: name={}, count={}, enabled={}", preset.name, preset.count, preset.enabled); + for item in general.list_presets().await?.presets { + println!("preset: name={}, count={}, enabled={}", item.name, item.count, item.enabled); + } + println!("empty presets: {}", general.list_empty_presets().await?.presets.len()); + println!("preset verified: {}", preset.verified.map_or("null".to_string(), |verified| verified.to_string())); + println!("preset quality default: {}", PresetQuality::default()); + // Exception Responses match general.error400().await { Ok(_) => {}, @@ -145,7 +185,7 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re println!("Invalid endpoint URL: htp://cloud.appwrite.io/v1"); - let _ = general.empty().await; + let (): () = general.empty().await?; // Test Queries test_queries(); @@ -155,6 +195,7 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re // Test Id Helpers test_id_helpers(); + test_topic_helpers(); // Test Operator Helpers test_operator_helpers(); @@ -313,6 +354,29 @@ fn test_id_helpers() { println!("{}", ID::custom("custom_id")); } +fn test_topic_helpers() { + println!("{}", topic::path(&["user", "123", "notification"]).unwrap()); + println!("{}", topic::path(&["org", "42", "user", "123"]).unwrap().path(&["notification"]).unwrap()); + println!("{}", topic::path(&["user"]).unwrap().any().path(&["notification"]).unwrap()); + println!("{}", topic::path(&["chat"]).unwrap().any().any().path(&["message"]).unwrap()); + println!("{}", topic::path(&["org"]).unwrap().any().path(&["logs"]).unwrap().all()); + println!("{}", topic::any().path(&["notification"]).unwrap()); + println!("{}", topic::all()); + let cases: Vec<(&str, Vec<&str>)> = vec![ + ("empty path", vec![]), + ("empty level", vec!["user", ""]), + ("slash", vec!["user/123"]), + ("plus", vec!["user", "a+b"]), + ("hash", vec!["user", "#"]), + ]; + for (name, levels) in cases { + match topic::path(&levels) { + Ok(_) => println!("Topic {}:failed", name), + Err(_) => println!("Topic {}:passed", name), + } + } +} + fn test_operator_helpers() { println!("{}", operator::increment()); println!("{}", operator::increment_with_max(5, 100)); From f8f2587aa31fff4921ed607bd40d362d65b2cc49 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 15 Oct 2026 11:11:39 +0100 Subject: [PATCH 3/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 342 ++- Cargo.toml | 2 +- README.md | 6 +- docs/examples/account/delete-consent-token.md | 4 +- docs/examples/account/delete-consent.md | 4 +- docs/examples/account/list-logs.md | 23 - docs/examples/apps/delete-installation.md | 4 +- docs/examples/apps/delete-key.md | 4 +- docs/examples/apps/delete-secret.md | 4 +- docs/examples/apps/delete-tokens.md | 4 +- docs/examples/apps/delete.md | 4 +- docs/examples/backups/delete-archive.md | 4 +- docs/examples/backups/delete-policy.md | 4 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 2 +- docs/examples/documentsdb/create-documents.md | 2 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 2 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/functions/update.md | 3 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/create-restoration.md | 5 +- docs/examples/mongo/delete-backup-policy.md | 4 +- docs/examples/mongo/delete-backup.md | 4 +- docs/examples/mongo/delete.md | 4 +- .../promote-restoration.md} | 9 +- docs/examples/mysql/create-restoration.md | 5 +- docs/examples/mysql/delete-backup-policy.md | 4 +- docs/examples/mysql/delete-backup.md | 4 +- docs/examples/mysql/delete.md | 4 +- .../promote-restoration.md} | 11 +- docs/examples/oauth2/approve.md | 2 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 2 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 2 +- docs/examples/oauth2/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 25 - .../organization/delete-installation.md | 4 +- docs/examples/organization/update-key.md | 25 - .../examples/postgresql/create-restoration.md | 5 +- .../postgresql/delete-backup-policy.md | 4 +- docs/examples/postgresql/delete-backup.md | 4 +- docs/examples/postgresql/delete.md | 4 +- .../promote-restoration.md} | 10 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- .../create-smtp-rule.md} | 12 +- docs/examples/sites/delete-log.md | 4 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 2 +- docs/examples/tablesdb/delete-migration.md | 4 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 2 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/delete-installation.md | 4 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 2 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 2 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 2 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- src/client.rs | 273 ++- src/enums/billing_plan_group.rs | 5 +- src/enums/execution_method.rs | 2 +- src/enums/execution_trigger.rs | 3 + src/enums/image_gravity.rs | 6 +- src/enums/mod.rs | 4 +- src/enums/organization_key_scopes.rs | 72 - src/enums/proxy_rule_protocol.rs | 26 + src/lib.rs | 5 +- src/models/activity_event.rs | 145 ++ src/models/activity_event_list.rs | 10 + src/models/additional_resource.rs | 30 + src/models/algo_argon2.rs | 20 + src/models/algo_bcrypt.rs | 5 + src/models/algo_md5.rs | 5 + src/models/algo_phpass.rs | 5 + src/models/algo_scrypt.rs | 25 + src/models/algo_scrypt_modified.rs | 20 + src/models/algo_sha.rs | 5 + src/models/app.rs | 130 + src/models/app_installation.rs | 45 + src/models/app_installation_list.rs | 10 + src/models/app_key.rs | 40 + src/models/app_key_list.rs | 10 + src/models/app_scope.rs | 25 + src/models/app_scope_list.rs | 10 + src/models/app_secret.rs | 40 + src/models/app_secret_list.rs | 10 + src/models/app_secret_plaintext.rs | 40 + src/models/apps_list.rs | 10 + src/models/attribute_bigint.rs | 30 + src/models/attribute_boolean.rs | 30 + src/models/attribute_datetime.rs | 30 + src/models/attribute_email.rs | 35 + src/models/attribute_enum.rs | 40 + src/models/attribute_float.rs | 30 + src/models/attribute_integer.rs | 30 + src/models/attribute_ip.rs | 35 + src/models/attribute_line.rs | 30 + src/models/attribute_list.rs | 10 + src/models/attribute_longtext.rs | 30 + src/models/attribute_mediumtext.rs | 30 + src/models/attribute_object.rs | 30 + src/models/attribute_point.rs | 30 + src/models/attribute_polygon.rs | 30 + src/models/attribute_relationship.rs | 55 + src/models/attribute_string.rs | 35 + src/models/attribute_text.rs | 30 + src/models/attribute_url.rs | 35 + src/models/attribute_varchar.rs | 35 + src/models/attribute_vector.rs | 35 + src/models/backup_archive.rs | 72 +- src/models/backup_archive_list.rs | 10 + src/models/backup_policy.rs | 50 + src/models/backup_policy_list.rs | 10 + src/models/backup_restoration.rs | 72 +- src/models/backup_restoration_list.rs | 10 + src/models/billing_plan.rs | 335 ++- src/models/billing_plan_addon_details.rs | 35 + src/models/billing_plan_supported_addons.rs | 15 + src/models/block.rs | 80 +- src/models/bucket.rs | 70 + src/models/bucket_list.rs | 10 + src/models/collection.rs | 60 + src/models/collection_list.rs | 10 + src/models/column_bigint.rs | 30 + src/models/column_boolean.rs | 30 + src/models/column_datetime.rs | 30 + src/models/column_email.rs | 35 + src/models/column_enum.rs | 40 + src/models/column_float.rs | 30 + src/models/column_index.rs | 45 + src/models/column_index_list.rs | 10 + src/models/column_integer.rs | 30 + src/models/column_ip.rs | 35 + src/models/column_line.rs | 30 + src/models/column_list.rs | 10 + src/models/column_longtext.rs | 30 + src/models/column_mediumtext.rs | 30 + src/models/column_point.rs | 30 + src/models/column_polygon.rs | 30 + src/models/column_relationship.rs | 55 + src/models/column_string.rs | 35 + src/models/column_text.rs | 30 + src/models/column_url.rs | 35 + src/models/column_varchar.rs | 35 + src/models/continent.rs | 10 + src/models/continent_list.rs | 10 + src/models/country.rs | 10 + src/models/country_list.rs | 10 + src/models/currency.rs | 35 + src/models/currency_list.rs | 10 + src/models/database.rs | 35 +- src/models/database_list.rs | 10 + src/models/database_migration.rs | 85 + src/models/database_migration_list.rs | 10 + src/models/database_status.rs | 74 +- src/models/database_status_connections.rs | 10 + src/models/database_status_replica.rs | 15 + src/models/database_status_volume.rs | 20 + src/models/dedicated_database.rs | 316 ++- src/models/dedicated_database_backup.rs | 60 + src/models/dedicated_database_backup_list.rs | 10 + .../dedicated_database_backup_storage.rs | 25 + src/models/dedicated_database_branch.rs | 69 +- src/models/dedicated_database_branch_list.rs | 10 + src/models/dedicated_database_execution.rs | 30 + .../dedicated_database_execution_column.rs | 10 + src/models/dedicated_database_extensions.rs | 15 + src/models/dedicated_database_list.rs | 10 + src/models/dedicated_database_member.rs | 15 + src/models/dedicated_database_operation.rs | 40 + .../dedicated_database_operation_list.rs | 10 + src/models/dedicated_database_pitr_windows.rs | 10 + src/models/dedicated_database_pooler.rs | 50 + src/models/dedicated_database_replicas.rs | 30 + src/models/dedicated_database_restoration.rs | 123 +- .../dedicated_database_restoration_list.rs | 10 + .../dedicated_database_specification.rs | 121 +- .../dedicated_database_specification_list.rs | 19 +- ...edicated_database_specification_pricing.rs | 68 - src/models/deployment.rs | 130 + src/models/deployment_list.rs | 10 + src/models/dev_key.rs | 104 - src/models/document.rs | 35 + src/models/document_list.rs | 10 + src/models/email_template.rs | 40 + src/models/email_template_list.rs | 10 + src/models/embedding.rs | 20 + src/models/embedding_list.rs | 10 + src/models/ephemeral_key.rs | 45 + src/models/execution.rs | 84 +- src/models/execution_list.rs | 10 + src/models/file.rs | 80 + src/models/file_list.rs | 10 + src/models/framework.rs | 25 + src/models/framework_adapter.rs | 20 + src/models/framework_list.rs | 10 + src/models/function.rs | 176 ++ src/models/function_list.rs | 10 + src/models/headers.rs | 10 + src/models/identity.rs | 69 +- src/models/identity_list.rs | 10 + src/models/index.rs | 40 + src/models/index_list.rs | 10 + src/models/insight.rs | 70 + src/models/insight_cta.rs | 20 + src/models/insight_list.rs | 10 + src/models/jwt.rs | 5 + src/models/key.rs | 45 + src/models/key_list.rs | 10 + src/models/language.rs | 15 + src/models/language_list.rs | 10 + src/models/locale.rs | 35 + src/models/locale_code.rs | 10 + src/models/locale_code_list.rs | 10 + src/models/log.rs | 235 -- src/models/log_list.rs | 49 - src/models/membership.rs | 75 + src/models/membership_list.rs | 10 + src/models/message.rs | 50 + src/models/message_list.rs | 10 + src/models/mfa_challenge.rs | 20 + src/models/mfa_challenge_secret.rs | 25 + src/models/mfa_factors.rs | 25 + src/models/mfa_recovery_codes.rs | 5 + src/models/mfa_type.rs | 10 + src/models/mock_number.rs | 20 + src/models/mock_number_list.rs | 10 + src/models/mod.rs | 36 +- src/models/o_auth2_amazon.rs | 20 + src/models/o_auth2_apple.rs | 68 +- src/models/o_auth2_appwrite.rs | 20 + src/models/o_auth2_auth0.rs | 44 +- src/models/o_auth2_authentik.rs | 25 + src/models/o_auth2_autodesk.rs | 20 + src/models/o_auth2_bitbucket.rs | 20 + src/models/o_auth2_bitly.rs | 20 + src/models/o_auth2_box.rs | 20 + src/models/o_auth2_cloudflare.rs | 20 + src/models/o_auth2_dailymotion.rs | 20 + src/models/o_auth2_discord.rs | 39 +- src/models/o_auth2_disqus.rs | 20 + src/models/o_auth2_dropbox.rs | 20 + src/models/o_auth2_etsy.rs | 20 + src/models/o_auth2_facebook.rs | 20 + src/models/o_auth2_figma.rs | 20 + src/models/o_auth2_fusion_auth.rs | 25 + src/models/o_auth2_github.rs | 39 +- src/models/o_auth2_gitlab.rs | 25 + src/models/o_auth2_google.rs | 63 +- src/models/o_auth2_hugging_face.rs | 20 + src/models/o_auth2_keycloak.rs | 30 + src/models/o_auth2_kick.rs | 20 + src/models/o_auth2_linkedin.rs | 20 + src/models/o_auth2_microsoft.rs | 44 +- src/models/o_auth2_notion.rs | 20 + src/models/o_auth2_oidc.rs | 65 +- src/models/o_auth2_okta.rs | 49 +- src/models/o_auth2_paypal.rs | 20 + src/models/o_auth2_podio.rs | 20 + src/models/o_auth2_provider_list.rs | 10 + src/models/o_auth2_resend.rs | 20 + src/models/o_auth2_salesforce.rs | 39 +- src/models/o_auth2_slack.rs | 20 + src/models/o_auth2_spotify.rs | 20 + src/models/o_auth2_stripe.rs | 20 + src/models/o_auth2_tradeshift.rs | 20 + src/models/o_auth2_twitch.rs | 20 + src/models/o_auth2_word_press.rs | 20 + src/models/o_auth2_x.rs | 20 + src/models/o_auth2_yahoo.rs | 20 + src/models/o_auth2_yandex.rs | 20 + src/models/o_auth2_zoho.rs | 39 +- src/models/o_auth2_zoom.rs | 20 + src/models/oauth2_approve.rs | 5 + src/models/oauth2_authorize.rs | 10 + src/models/oauth2_consent.rs | 50 + src/models/oauth2_consent_list.rs | 10 + src/models/oauth2_consent_token.rs | 55 + src/models/oauth2_consent_token_list.rs | 10 + src/models/oauth2_device_authorization.rs | 30 + src/models/oauth2_grant.rs | 60 + src/models/oauth2_organization.rs | 5 + src/models/oauth2_organization_list.rs | 10 + src/models/oauth2_par.rs | 10 + src/models/oauth2_project.rs | 15 + src/models/oauth2_project_list.rs | 10 + src/models/oauth2_reject.rs | 5 + src/models/oauth2_token.rs | 25 + src/models/organization.rs | 166 +- src/models/passkey.rs | 25 + src/models/passkey_challenge.rs | 25 + src/models/passkey_list.rs | 10 + src/models/phone.rs | 15 + src/models/phone_list.rs | 10 + src/models/platform_android.rs | 44 +- src/models/platform_apple.rs | 25 + src/models/platform_linux.rs | 25 + src/models/platform_list.rs | 10 + src/models/platform_web.rs | 25 + src/models/platform_windows.rs | 25 + src/models/policy_deny_aliased_email.rs | 10 + src/models/policy_deny_corporate_email.rs | 10 + src/models/policy_deny_disposable_email.rs | 10 + src/models/policy_deny_free_email.rs | 10 + src/models/policy_list.rs | 10 + src/models/policy_membership_privacy.rs | 35 + src/models/policy_mfa_factors.rs | 25 + src/models/policy_passkey.rs | 15 + src/models/policy_password_dictionary.rs | 10 + src/models/policy_password_history.rs | 10 + src/models/policy_password_personal_data.rs | 10 + src/models/policy_password_strength.rs | 30 + src/models/policy_session_alert.rs | 10 + src/models/policy_session_duration.rs | 10 + src/models/policy_session_invalidation.rs | 10 + src/models/policy_session_limit.rs | 10 + src/models/policy_user_limit.rs | 10 + src/models/postgres_extension.rs | 20 + src/models/presence.rs | 30 + src/models/presence_list.rs | 10 + src/models/program.rs | 45 + src/models/project.rs | 139 +- src/models/project_auth_method.rs | 5 + src/models/project_list.rs | 10 + src/models/project_protocol.rs | 5 + src/models/project_service.rs | 5 + src/models/provider.rs | 40 + src/models/provider_list.rs | 10 + src/models/proxy_invalidation.rs | 20 + src/models/proxy_rule.rs | 82 +- src/models/proxy_rule_list.rs | 10 + src/models/report.rs | 55 + src/models/report_list.rs | 10 + src/models/resource_token.rs | 35 + src/models/resource_token_list.rs | 10 + src/models/row.rs | 35 + src/models/row_list.rs | 10 + src/models/runtime.rs | 40 + src/models/runtime_list.rs | 10 + src/models/session.rs | 145 ++ src/models/session_list.rs | 10 + src/models/site.rs | 165 ++ src/models/site_list.rs | 10 + src/models/specification.rs | 20 + src/models/specification_list.rs | 10 + src/models/subscriber.rs | 40 + src/models/subscriber_list.rs | 10 + src/models/table.rs | 60 + src/models/table_list.rs | 10 + src/models/target.rs | 40 + src/models/target_list.rs | 10 + src/models/team.rs | 25 + src/models/team_list.rs | 10 + src/models/token.rs | 30 + src/models/token_secret.rs | 30 + src/models/topic.rs | 44 +- src/models/topic_list.rs | 10 + src/models/transaction.rs | 30 + src/models/transaction_list.rs | 10 + src/models/usage_billing_plan.rs | 118 +- src/models/user.rs | 75 + src/models/user_list.rs | 10 + src/models/variable.rs | 40 + src/models/variable_list.rs | 10 + src/models/vectorsdb_collection.rs | 65 + src/models/vectorsdb_collection_list.rs | 10 + src/models/webhook.rs | 67 +- src/models/webhook_list.rs | 10 + src/query/builder.rs | 622 +++++ src/{query.rs => query/mod.rs} | 573 +++++ src/services/account.rs | 177 +- src/services/activities.rs | 12 +- src/services/advisor.rs | 61 +- src/services/apps.rs | 328 ++- src/services/avatars.rs | 27 +- src/services/backups.rs | 82 +- src/services/databases.rs | 1870 +++++++++++++-- src/services/documents_db.rs | 741 +++++- src/services/functions.rs | 390 ++- src/services/messaging.rs | 352 ++- src/services/mongo.rs | 503 +++- src/services/mysql.rs | 543 ++++- src/services/oauth2.rs | 47 +- src/services/organization.rs | 230 +- src/services/postgresql.rs | 591 ++++- src/services/presences.rs | 49 +- src/services/project.rs | 212 +- src/services/proxy.rs | 64 +- src/services/sites.rs | 381 ++- src/services/storage.rs | 209 +- src/services/tables_db.rs | 2092 +++++++++++++++-- src/services/teams.rs | 286 ++- src/services/tokens.rs | 85 +- src/services/users.rs | 500 +++- src/services/vectors_db.rs | 669 +++++- src/services/webhooks.rs | 49 +- src/topic.rs | 158 ++ tests/tests.rs | 110 +- 419 files changed, 20531 insertions(+), 2473 deletions(-) delete mode 100644 docs/examples/account/list-logs.md rename docs/examples/{organization/get-key.md => mongo/promote-restoration.md} (71%) rename docs/examples/{users/list-logs.md => mysql/promote-restoration.md} (68%) delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/update-key.md rename docs/examples/{organization/list-keys.md => postgresql/promote-restoration.md} (67%) rename docs/examples/{organization/delete-key.md => proxy/create-smtp-rule.md} (64%) delete mode 100644 src/enums/organization_key_scopes.rs create mode 100644 src/enums/proxy_rule_protocol.rs delete mode 100644 src/models/dedicated_database_specification_pricing.rs delete mode 100644 src/models/dev_key.rs delete mode 100644 src/models/log.rs delete mode 100644 src/models/log_list.rs create mode 100644 src/query/builder.rs rename src/{query.rs => query/mod.rs} (67%) create mode 100644 src/topic.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index ed2831c..d88c77b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.16.0] - TBD +## [0.20.0] - TBD ### Added - Initial release of Appwrite Rust SDK -- Full support for Appwrite API 2.0.0 +- Full support for Appwrite API 2.5.0 - Async/await support with tokio runtime - Built-in error handling with custom error types - File upload support with automatic chunking @@ -22,34 +22,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Automatic JSON serialization/deserialization ### Features -- Account service with 59 methods +- Account service with 71 methods - Activities service with 2 methods - Apps service with 22 methods -- Avatars service with 9 methods +- Avatars service with 11 methods - Backups service with 12 methods - Databases service with 71 methods - DocumentsDB service with 37 methods +- Domains service with 47 methods - Embeddings service with 1 methods - Functions service with 26 methods - Graphql service with 2 methods - Locale service with 8 methods -- Messaging service with 54 methods -- Mongo service with 31 methods -- Mysql service with 34 methods -- Oauth2 service with 12 methods +- Messaging service with 56 methods +- Mongo service with 32 methods +- Mysql service with 35 methods +- Oauth2 service with 13 methods - Organization service with 23 methods -- Postgresql service with 37 methods +- Postgresql service with 38 methods - Presences service with 5 methods -- Project service with 105 methods -- Proxy service with 9 methods +- Project service with 116 methods +- Proxy service with 10 methods - Advisor service with 5 methods - Sites service with 25 methods - Storage service with 13 methods - TablesDB service with 81 methods - Teams service with 18 methods - Tokens service with 5 methods -- Users service with 50 methods +- Users service with 53 methods - VectorsDB service with 36 methods +- Waf service with 13 methods - Webhooks service with 6 methods ### Services @@ -68,7 +70,6 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `list_identities()` - Get the list of identities for the currently logged in user. - `delete_identity()` - Delete an identity by its unique ID. -- `list_logs()` - 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. - `update_mfa()` - Enable or disable MFA on an account. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. @@ -89,6 +90,12 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_name()` - Update currently logged in user account name. +- `list_passkeys()` - Get the list of verified passkeys registered by the currently logged in user. +- `create_passkey()` - 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. +- `get_passkey()` - Get a verified passkey of the currently logged in user by its unique ID. +- `update_passkey()` - Rename a passkey of the currently logged in user. +- `delete_passkey()` - 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. +- `update_passkey_verification()` - 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. - `update_password()` - Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. - `update_phone()` - Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. - `get_prefs()` - Get the preferences as a key-value object for the currently logged in user. @@ -97,12 +104,30 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_recovery()` - 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. +- `create_recovery_otp()` - 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. + +- `update_recovery_otp()` - 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. + - `list_sessions()` - Get the list of active sessions across different devices for the currently logged in user. -- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. +- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. - `create_anonymous_session()` - Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). -- `create_email_password_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. +- `create_email_password_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 limits](https://appwrite.io/docs/authentication-security#limits). +- `create_id_token_session()` - 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). + - `update_magic_url_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `update_phone_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `create_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -122,7 +147,11 @@ A user is limited to 10 active sessions at a time by default. [Learn more about If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create 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). +- `create_passkey_token()` - 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. +- `update_passkey_token()` - 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. - `create_phone_token()` - 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 /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. 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). @@ -136,6 +165,12 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ - `update_email_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. - `update_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. +- `create_email_verification_otp()` - 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. + +- `update_email_verification_otp()` - 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. + - `create_phone_verification()` - Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. - `update_phone_verification()` - Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -197,9 +232,11 @@ You can use the color and background params to change the avatar colors. By defa When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. -- `get_photo()` - 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. +- `get_photo()` - Returns the best available profile photo for a user. The endpoint tries 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, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. +- `update_photo()` - 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. +- `delete_photo()` - 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. - `get_qr()` - 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. - `get_screenshot()` - Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -332,7 +369,7 @@ The Databases service allows you to create structured collections of documents, - `increment_document_attribute()` - Increment a specific attribute of a document by a given value. - `list_indexes()` - List indexes in the collection. - `create_index()` - Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. - `get_index()` - Get an index by its unique ID. - `delete_index()` - Delete an index. @@ -341,7 +378,7 @@ Attributes can be `key`, `fulltext`, and `unique`. - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -379,6 +416,127 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Domains + +- `list()` - List all domains registered for this project. This endpoint supports pagination. +- `create()` - 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. +- `get_price()` - Get the registration price for a domain name. +- `list_prices()` - 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. +- `get()` - Get a domain by its unique ID. +- `delete()` - 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. +- `update_nameservers()` - Update the registrar nameservers for the given domain. When nameservers are not provided, +the domain will be updated to use Appwrite nameservers. +- `verify_nameservers()` - 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. +- `get_preset_google_workspace()` - List Google Workspace DNS records. +- `create_preset_google_workspace()` - Add Google Workspace DNS records to the domain. This will create the required MX records +for Google Workspace email hosting. +- `get_preset_i_cloud()` - List iCloud DNS records. +- `create_preset_i_cloud()` - Add iCloud DNS records to the domain. This will create the required MX and SPF records +for using iCloud email services with your domain. +- `get_preset_mailgun()` - List Mailgun DNS records. +- `create_preset_mailgun()` - Add Mailgun DNS records to the domain. This endpoint will create the required DNS records +for Mailgun in the specified domain. +- `get_preset_outlook()` - List Outlook DNS records. +- `create_preset_outlook()` - Add Outlook DNS records to the domain. This will create the required MX records +for setting up Outlook email hosting for your domain. +- `get_preset_proton_mail()` - List ProtonMail DNS records. +- `create_preset_proton_mail()` - Add ProtonMail DNS records to the domain. This will create the required MX records +for using ProtonMail with your custom domain. +- `get_preset_zoho()` - List Zoho DNS records. +- `create_preset_zoho()` - Add Zoho Mail DNS records to the domain. This will create the required MX records +for setting up Zoho Mail on your domain. +- `list_records()` - List DNS records for a given domain. You can use this endpoint to list all the DNS records +associated with your domain. +- `create_record_a()` - 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. +- `update_record_a()` - 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. +- `create_record_aaaa()` - 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. +- `update_record_aaaa()` - 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. +- `create_record_alias()` - 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. +- `update_record_alias()` - 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. +- `create_record_caa()` - 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. +- `update_record_caa()` - 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. +- `create_record_cname()` - 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'. +- `update_record_cname()` - Update an existing CNAME record for the given domain. +- `create_record_https()` - 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. +- `update_record_https()` - 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. +- `create_record_mx()` - 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. +- `update_record_mx()` - Update an existing MX record for the given domain. +- `create_record_ns()` - 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. +- `update_record_ns()` - 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. +- `create_record_srv()` - 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. +- `update_record_srv()` - 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 +- `create_record_txt()` - 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. +- `update_record_txt()` - 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. +- `get_record()` - 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. +- `delete_record()` - Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record +from a specific domain. +- `update_team()` - 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. +- `get_transfer_status()` - Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. +- `get_zone()` - 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. +- `update_zone()` - 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. + #### Embeddings - `create_text_embeddings()` - Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. @@ -463,6 +621,8 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `create_apns_provider()` - Create a new Apple Push Notification service provider. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. +- `create_appwrite_provider()` - Create a new Appwrite push provider. +- `update_appwrite_provider()` - Update an Appwrite push provider by its unique ID. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `update_fcm_provider()` - Update a Firebase Cloud Messaging provider by its unique ID. @@ -509,7 +669,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -535,7 +695,13 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. - `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. - `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `promote_restoration()` - Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. - `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. @@ -543,7 +709,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -561,7 +727,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. - `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. - `update_credentials()` - Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. -- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. +- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. - `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. - `update_maintenance()` - Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. - `create_migration()` - Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. @@ -572,7 +738,13 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. - `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. - `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `promote_restoration()` - Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. - `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. @@ -584,6 +756,7 @@ The OAuth2 service allows you to authorize apps and issue standards-based OAuth2 - `create_device_authorization()` - Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. - `create_grant()` - Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. - `get_grant()` - Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. +- `introspect()` - 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. - `list_organizations()` - 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. - `create_par()` - Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. - `list_projects()` - List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. @@ -601,11 +774,6 @@ The Organization service allows you to manage organization-level projects. - `get_installation()` - Get an app installation on the organization by its unique ID. Any organization member can read installations. - `update_installation()` - Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. - `delete_installation()` - Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked. -- `list_keys()` - Get a list of all API keys from the current organization. -- `create_key()` - Create a new organization API key. -- `get_key()` - Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. -- `update_key()` - Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. -- `delete_key()` - Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - `list_memberships()` - Get a list of all memberships from the current organization. - `create_membership()` - 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. - `get_membership()` - Get a membership from the current organization by its unique ID. @@ -616,12 +784,19 @@ The Organization service allows you to manage organization-level projects. - `get_project()` - Get a project. - `update_project()` - Update a project by its unique ID. - `delete_project()` - Delete a project by its unique ID. +- `list_project_keys()` - Get a list of all API keys of a project in your organization. +- `create_ephemeral_project_key()` - Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + +You can also create a standard API key if you need a longer-lived key instead. +- `get_project_key()` - Get a project key by its unique ID. +- `update_project_key()` - Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. +- `delete_project_key()` - Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. #### Postgresql - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -639,7 +814,7 @@ The Organization service allows you to manage organization-level projects. - `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. - `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. - `update_credentials()` - Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. -- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. +- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. - `list_extensions()` - List installed and available extensions for a PostgreSQL database. - `create_extension()` - Install a database extension. Only available for PostgreSQL databases. The install runs asynchronously; poll the extensions list endpoint for status. - `delete_extension()` - Uninstall a database extension from a PostgreSQL database. The uninstall runs asynchronously; poll the extensions list endpoint for status. @@ -653,7 +828,13 @@ The Organization service allows you to manage organization-level projects. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. - `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. - `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `promote_restoration()` - Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. - `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. @@ -675,6 +856,11 @@ The Project service allows you to manage all the projects in your Appwrite serve - `get()` - Get a project. - `delete()` - Delete a project. - `update_auth_method()` - Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. +- `list_environments()` - Get a list of all environments of the project. You can use the query params to filter your results. +- `create_environment()` - Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. +- `get_environment()` - Get an environment of the project by its unique ID. +- `update_environment()` - Update the name of an environment of the project. +- `delete_environment()` - Delete an environment of the project, with all of its resources and users. - `list_keys()` - Get a list of all API keys from the current project. - `create_ephemeral_key()` - Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. @@ -712,6 +898,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_gitlab()` - Update the project OAuth2 Gitlab configuration. - `update_o_auth2_google()` - Update the project OAuth2 Google configuration. - `update_o_auth2_hugging_face()` - Update the project OAuth2 Hugging Face configuration. +- `update_o_auth2_kakao()` - Update the project OAuth2 Kakao configuration. - `update_o_auth2_keycloak()` - Update the project OAuth2 Keycloak configuration. - `update_o_auth2_kick()` - Update the project OAuth2 Kick configuration. - `update_o_auth2_linkedin()` - Update the project OAuth2 Linkedin configuration. @@ -727,9 +914,11 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_slack()` - Update the project OAuth2 Slack configuration. - `update_o_auth2_spotify()` - Update the project OAuth2 Spotify configuration. - `update_o_auth2_stripe()` - Update the project OAuth2 Stripe configuration. +- `update_o_auth2_tik_tok()` - Update the project OAuth2 TikTok configuration. - `update_o_auth2_tradeshift()` - Update the project OAuth2 Tradeshift configuration. - `update_o_auth2_tradeshift_sandbox()` - Update the project OAuth2 Tradeshift Sandbox configuration. - `update_o_auth2_twitch()` - Update the project OAuth2 Twitch configuration. +- `update_o_auth2_webflow()` - Update the project OAuth2 Webflow configuration. - `update_o_auth2_word_press()` - Update the project OAuth2 WordPress configuration. - `update_o_auth2_x()` - Update the project OAuth2 X configuration. - `update_o_auth2_yahoo()` - Update the project OAuth2 Yahoo configuration. @@ -739,7 +928,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `get_o_auth2_provider()` - Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. - `list_platforms()` - Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. - `create_android_platform()` - Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. -- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. +- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. - `create_apple_platform()` - Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. - `update_apple_platform()` - Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. - `create_linux_platform()` - Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. @@ -757,11 +946,14 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_deny_free_email_policy()` - Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. - `update_membership_privacy_policy()` - Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. - `update_mfa_factors_policy()` - Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. +- `update_passkey_policy()` - 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. - `update_password_dictionary_policy()` - 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. - `update_password_history_policy()` - Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. - `update_password_personal_data_policy()` - Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. +- `update_password_pwned_policy()` - 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. +- `update_password_rotation_policy()` - 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. - `update_password_strength_policy()` - Update the password strength requirements for users in the project. - `update_session_alert_policy()` - Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. - `update_session_duration_policy()` - Update maximum duration how long sessions created within a project should stay active for. @@ -787,6 +979,8 @@ The Proxy Service allows you to configure actions for your domains beyond DNS co - `create_invalidation()` - Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. 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. - `list_rules()` - Get a list of all the proxy rules. You can use the query params to filter your results. - `create_api_rule()` - Create a new proxy rule for serving Appwrite's API on custom domain. @@ -800,6 +994,7 @@ Rule ID is automatically generated as MD5 hash of a rule domain for performance - `create_site_rule()` - Create a new proxy rule for serving Appwrite Site on custom domain. Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. +- `create_smtp_rule()` - Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. - `get_rule()` - Get a proxy rule by its unique ID. - `delete_rule()` - Delete a proxy rule by its unique ID. - `update_rule_status()` - If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. @@ -877,7 +1072,7 @@ The TablesDB service allows you to create structured tables of columns, query an - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -889,10 +1084,10 @@ The TablesDB service allows you to create structured tables of columns, query an - `delete()` - Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. - `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. - `list_migrations()` - List the dedicated migrations for a TablesDB database. A database has at most one in-flight migration. -- `create_migration()` - Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. +- `create_migration()` - Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. - `get_migration()` - Get a single dedicated migration for a TablesDB database by its ID. - `delete_migration()` - Abort an in-flight TablesDB dedicated migration. Only allowed before cutover; once the migration has cut over it cannot be aborted. -- `create_cutover()` - Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. +- `create_cutover()` - Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. - `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. @@ -946,6 +1141,8 @@ The TablesDB service allows you to create structured tables of columns, query an - `update_polygon_column()` - Update a polygon column. Changing the `default` value will not update already existing rows. - `create_relationship_column()` - Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). +- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + - `create_string_column()` - Create a string column. - `update_string_column()` - Update a string column. Changing the `default` value will not update already existing rows. @@ -964,11 +1161,9 @@ The TablesDB service allows you to create structured tables of columns, query an - `get_column()` - Get column by ID. - `delete_column()` - Deletes a column. -- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - - `list_indexes()` - List indexes on the table. - `create_index()` - Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. - `get_index()` - Get index by ID. - `delete_index()` - Delete an index. - `list_rows()` - Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -1041,13 +1236,12 @@ The Users service allows you to manage your project users. - `get()` - Get a user by its unique ID. - `delete()` - Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. - `update_email()` - Update the user email by its unique ID. -- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. 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. - `create_jwt()` - Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. - `update_labels()` - Update the user labels by its unique ID. Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. -- `list_logs()` - Get the user activity logs list by its unique ID. - `list_memberships()` - Get the user membership list by its unique ID. - `update_mfa()` - Enable or disable MFA on a user account. - `update_mfa()` - Enable or disable MFA on a user account. @@ -1063,6 +1257,10 @@ Labels can be used to grant access to resources. While teams are a way for user& - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `update_name()` - Update the user name by its unique ID. +- `list_passkeys()` - Get the list of verified passkeys registered by a user. +- `get_passkey()` - Get a verified passkey of a user by its unique ID. +- `update_passkey()` - Rename a passkey of a user. +- `delete_passkey()` - Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. - `update_password()` - Update the user password by its unique ID. - `update_phone()` - Update the user phone by its unique ID. - `get_prefs()` - Get the user preferences by its unique ID. @@ -1089,7 +1287,7 @@ If you want to generate a token for a custom authentication flow, use the [POST - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -1127,6 +1325,35 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Waf + +- `list_rules()` - List WAF rules for the current project. + +- `create_bypass_rule()` - 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. + +- `update_bypass_rule()` - 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. + +- `create_challenge_rule()` - 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. + +- `update_challenge_rule()` - 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. + +- `create_deny_rule()` - 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. + +- `update_deny_rule()` - 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. + +- `create_rate_limit_rule()` - 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. + +- `update_rate_limit_rule()` - 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. + +- `create_redirect_rule()` - 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. + +- `update_redirect_rule()` - 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. + +- `get_rule()` - Get a WAF rule by its ID. + +- `delete_rule()` - Delete a WAF rule. + + #### Webhooks The Webhooks service allows you to manage your project webhooks. - `list()` - Get a list of all webhooks belonging to the project. You can use the query params to filter your results. @@ -1149,7 +1376,6 @@ The Webhooks service allows you to manage your project webhooks. - `UserList` - Users List - `SessionList` - Sessions List - `IdentityList` - Identities List -- `LogList` - Logs List - `FileList` - Files List - `BucketList` - Buckets List - `ResourceTokenList` - Resource Tokens List @@ -1236,7 +1462,6 @@ The Webhooks service allows you to manage your project webhooks. - `Row` - Row - `Document` - Document - `Presence` - Presence -- `Log` - Log - `User` - User - `AlgoMd5` - AlgoMD5 - `AlgoSha` - AlgoSHA @@ -1245,6 +1470,7 @@ The Webhooks service allows you to manage your project webhooks. - `AlgoScrypt` - AlgoScrypt - `AlgoScryptModified` - AlgoScryptModified - `AlgoArgon2` - AlgoArgon2 +- `Account` - Account - `Preferences` - Preferences - `Session` - Session - `Identity` - Identity @@ -1271,7 +1497,6 @@ The Webhooks service allows you to manage your project webhooks. - `Webhook` - Webhook - `Key` - Key - `EphemeralKey` - Ephemeral Key -- `DevKey` - DevKey - `MockNumber` - Mock Number - `OAuth2Github` - OAuth2GitHub - `OAuth2Discord` - OAuth2Discord @@ -1288,6 +1513,7 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Yandex` - OAuth2Yandex - `OAuth2X` - OAuth2X - `OAuth2WordPress` - OAuth2WordPress +- `OAuth2Webflow` - OAuth2Webflow - `OAuth2Twitch` - OAuth2Twitch - `OAuth2Stripe` - OAuth2Stripe - `OAuth2Spotify` - OAuth2Spotify @@ -1317,11 +1543,15 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Apple` - OAuth2Apple - `OAuth2Microsoft` - OAuth2Microsoft - `OAuth2Resend` - OAuth2Resend +- `OAuth2TikTok` - OAuth2TikTok +- `OAuth2Kakao` - OAuth2Kakao - `OAuth2ProviderList` - OAuth2 Providers List - `PolicyPasswordDictionary` - Policy Password Dictionary - `PolicyPasswordHistory` - Policy Password History - `PolicyPasswordStrength` - Policy Password Strength - `PolicyPasswordPersonalData` - Policy Password Personal Data +- `PolicyPasswordPwned` - Policy Password Pwned +- `PolicyPasswordRotation` - Policy Password Rotation - `PolicySessionAlert` - Policy Session Alert - `PolicySessionDuration` - Policy Session Duration - `PolicySessionInvalidation` - Policy Session Invalidation @@ -1329,6 +1559,11 @@ The Webhooks service allows you to manage your project webhooks. - `PolicyUserLimit` - Policy User Limit - `PolicyMembershipPrivacy` - Policy Membership Privacy - `PolicyMfaFactors` - Policy MFA Factors +- `PolicyPasskey` - Policy Passkey +- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email +- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email +- `PolicyDenyFreeEmail` - Policy Deny Free Email +- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `PlatformWeb` - Platform Web - `PlatformApple` - Platform Apple - `PlatformAndroid` - Platform Android @@ -1347,6 +1582,10 @@ The Webhooks service allows you to manage your project webhooks. - `EmailTemplate` - EmailTemplate - `MfaChallenge` - MFA Challenge - `MfaChallengeSecret` - MFA Challenge Secret +- `TokenSecret` - Token Secret +- `Passkey` - Passkey +- `PasskeyChallenge` - Passkey Challenge +- `PasskeyList` - Passkeys List - `MfaRecoveryCodes` - MFA Recovery Codes - `MfaType` - MFAType - `MfaFactors` - MFAFactors @@ -1381,6 +1620,10 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseExecutionColumn` - ExecutionColumn - `DedicatedDatabaseRestoration` - Restoration - `DatabaseStatus` - Status +- `DnsRecord` - DNSRecord +- `Domain` - Domain +- `DomainPrice` - DomainPrice +- `DomainTransferStatus` - domainTransferStatus - `DedicatedDatabaseExtensions` - Extensions - `DedicatedDatabaseMember` - Member - `DedicatedDatabaseOperation` - Operation @@ -1390,10 +1633,6 @@ The Webhooks service allows you to manage your project webhooks. - `Organization` - Organization - `DedicatedDatabasePITRWindows` - PITRWindows - `BackupPolicy` - backup -- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email -- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email -- `PolicyDenyFreeEmail` - Policy Deny Free Email -- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `DedicatedDatabasePooler` - PoolerConfig - `PostgresExtension` - Postgres extension - `Program` - Program @@ -1401,7 +1640,6 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseRestorationList` - Dedicated database restorations list - `DedicatedDatabaseSpecification` - Specification - `DedicatedDatabaseSpecificationList` - SpecificationList -- `DedicatedDatabaseSpecificationPricing` - SpecificationPricing - `DatabaseStatusConnections` - Connections - `DatabaseStatusReplica` - Replica - `DatabaseStatusVolume` - Volume @@ -1419,8 +1657,15 @@ The Webhooks service allows you to manage your project webhooks. - `Oauth2DeviceAuthorization` - OAuth2 Device Authorization - `Oauth2PAR` - OAuth2 PAR - `Oauth2Token` - OAuth2 Token +- `Oauth2Introspection` - OAuth2 Introspection - `Oauth2Consent` - OAuth2 Consent - `Oauth2ConsentToken` - OAuth2 Consent Token +- `WafRuleBypass` - WafRuleBypass +- `WafRuleDeny` - WafRuleDeny +- `WafRuleChallenge` - WafRuleChallenge +- `WafRuleRateLimit` - WafRuleRateLimit +- `WafRuleRedirect` - WafRuleRedirect +- `WafRuleList` - WAF rule list - `Oauth2Project` - OAuth2 Project - `Oauth2Organization` - OAuth2 Organization - `Oauth2ProjectList` - OAuth2 accessible projects list @@ -1433,6 +1678,9 @@ The Webhooks service allows you to manage your project webhooks. - `BackupRestorationList` - Backup restoration list - `DatabaseMigrationList` - Database Migrations List - `DedicatedDatabaseList` - Dedicated databases list +- `DnsRecordsList` - DNS records list +- `DomainPricesList` - Domain prices list +- `DomainsList` - Domains list - `AppsList` - Apps list - `AppSecretList` - App secrets list - `AppScopeList` - App scopes list @@ -1453,4 +1701,4 @@ The Webhooks service allows you to manage your project webhooks. - File upload examples - Query builder documentation -[0.16.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.16.0 +[0.20.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.20.0 diff --git a/Cargo.toml b/Cargo.toml index b5198a4..784ba2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "appwrite" -version = "0.19.0" +version = "0.20.0" edition = "2021" rust-version = "1.83" authors = ["appwrite"] diff --git a/README.md b/README.md index 3b784e1..26523cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Appwrite Rust SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-rust.svg) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg) [![Crates.io](https://img.shields.io/crates/v/appwrite.svg)](https://crates.io/crates/appwrite) [![Documentation](https://docs.rs/appwrite/badge.svg)](https://docs.rs/appwrite) -**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-rust/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-rust/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 Rust 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) @@ -17,7 +17,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -appwrite = "0.19.0" +appwrite = "0.20.0" tokio = { version = "1.48", features = ["full"] } ``` diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index a6f2987..6314ff5 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent_token( + account.delete_consent_token( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index 084f1c6..c850bcd 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent( + account.delete_consent( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 8f332bf..0000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,23 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Account; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_session(""); // The user session to authenticate with - - let account = Account::new(&client); - - let result = account.list_logs( - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index 320dac4..8abf001 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_installation( + apps.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index 1d3bf37..2b3c9ae 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_key( + apps.delete_key( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index 1fa363c..86ba5da 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_secret( + apps.delete_secret( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index febc173..dc71045 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_tokens( + apps.delete_tokens( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index 84d8cfd..ab57e98 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete( + apps.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index d75868a..5929752 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_archive( + backups.delete_archive( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index 05e44f4..2368cc2 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_policy( + backups.delete_policy( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index f469178..249a02f 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index b7389d9..8e7aeef 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DatabasesIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 2d75876..7642b78 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 6ef035f..e37391a 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1c60d5c..5154b92 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index 2b7534c..3ace295 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DocumentsDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index be2ad02..f2807ca 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index d6ba165..40e58ed 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 8f945bb..de4f2e5 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let embeddings = Embeddings::new(&client); let result = embeddings.create_text_embeddings( - vec![], + vec!["Appwrite helps developers build applications.".into(), "Find documents with semantic search.".into()], Some(appwrite::enums::EmbeddingModel::NomicEmbedText) // optional ).await?; diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 0ef1cfa..b452dc5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -34,7 +34,8 @@ async fn main() -> Result<(), Box> { Some("s-1vcpu-512mb"), // optional Some("s-1vcpu-512mb"), // optional Some(0), // optional - Some(0) // optional + Some(0), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 2a28b83..0746b1e 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = messaging.create_twilio_provider( "", "", - Some("+12065550100"), // optional + Some(""), // optional Some(""), // optional Some(""), // optional Some(false) // optional diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 2e93a7a..e1028f2 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -16,7 +16,10 @@ async fn main() -> Result<(), Box> { Some("backup"), // optional Some(""), // optional Some(""), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("in_place"), // optional + Some(""), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md index 9114d69..05d5d23 100644 --- a/docs/examples/mongo/delete-backup-policy.md +++ b/docs/examples/mongo/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup_policy( + mongo.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md index d596d40..b992f13 100644 --- a/docs/examples/mongo/delete-backup.md +++ b/docs/examples/mongo/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup( + mongo.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md index 777f263..3f9734f 100644 --- a/docs/examples/mongo/delete.md +++ b/docs/examples/mongo/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete( + mongo.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/mongo/promote-restoration.md similarity index 71% rename from docs/examples/organization/get-key.md rename to docs/examples/mongo/promote-restoration.md index 2d01434..4164174 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/mongo/promote-restoration.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Organization; +use appwrite::services::Mongo; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,10 +9,11 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let organization = Organization::new(&client); + let mongo = Mongo::new(&client); - let result = organization.get_key( - "" + let result = mongo.promote_restoration( + "", + "" ).await?; let _ = result; diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index f194175..269a70a 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -16,7 +16,10 @@ async fn main() -> Result<(), Box> { Some("backup"), // optional Some(""), // optional Some(""), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("in_place"), // optional + Some(""), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md index 39ae07e..2e859af 100644 --- a/docs/examples/mysql/delete-backup-policy.md +++ b/docs/examples/mysql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup_policy( + mysql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md index 2e0b931..40b6302 100644 --- a/docs/examples/mysql/delete-backup.md +++ b/docs/examples/mysql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup( + mysql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md index db5d332..ab8b4b9 100644 --- a/docs/examples/mysql/delete.md +++ b/docs/examples/mysql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete( + mysql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/mysql/promote-restoration.md similarity index 68% rename from docs/examples/users/list-logs.md rename to docs/examples/mysql/promote-restoration.md index 6f5b333..966d742 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/mysql/promote-restoration.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Users; +use appwrite::services::Mysql; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,12 +9,11 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let users = Users::new(&client); + let mysql = Mysql::new(&client); - let result = users.list_logs( - "", - Some(vec![]), // optional - Some(false) // optional + let result = mysql.promote_restoration( + "", + "" ).await?; let _ = result; diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index ff39bf6..ee6c153 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 2593e9b..45ada9f 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index db2c875..3a93e0b 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index c894372..a026965 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index a208289..6bf1198 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 3e344a2..f334c66 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index eecf973..8bc0d41 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some("https://example.com"), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index fbd475d..8270c93 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index c440370..6f32686 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 30c6e9f..d21afc2 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index a303692..645c41d 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 9469837..638b47e 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 5ec24d8..0000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.create_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index d4cb99d..af3dc97 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let organization = Organization::new(&client); - let result = organization.delete_installation( + organization.delete_installation( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index a798005..0000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.update_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index bac2e85..52bf142 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -16,7 +16,10 @@ async fn main() -> Result<(), Box> { Some("backup"), // optional Some(""), // optional Some(""), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("in_place"), // optional + Some(""), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md index 1362635..4eeef55 100644 --- a/docs/examples/postgresql/delete-backup-policy.md +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup_policy( + postgresql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md index f30ba45..f5ba8fd 100644 --- a/docs/examples/postgresql/delete-backup.md +++ b/docs/examples/postgresql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup( + postgresql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md index 4d9207e..8a966ce 100644 --- a/docs/examples/postgresql/delete.md +++ b/docs/examples/postgresql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete( + postgresql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/postgresql/promote-restoration.md similarity index 67% rename from docs/examples/organization/list-keys.md rename to docs/examples/postgresql/promote-restoration.md index 1466645..7813d3d 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Organization; +use appwrite::services::Postgresql; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,11 +9,11 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let organization = Organization::new(&client); + let postgresql = Postgresql::new(&client); - let result = organization.list_keys( - Some(vec![]), // optional - Some(false) // optional + let result = postgresql.promote_restoration( + "", + "" ).await?; let _ = result; diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 93d1dc4..357e4d6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.create_ephemeral_key( - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], 600 ).await?; diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index cb5f2ce..a62073f 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); project.create_smtp_test( - vec![] + vec!["recipient@example.com".into()] ).await?; Ok(()) diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 12b0282..1c6148a 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = project.update_key( "", "", - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], Some("2020-10-15T06:38:00.000+00:00") // optional ).await?; diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index 541993e..e9b0ea4 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.update_labels( - vec![] + vec!["production".into()] ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index f96eb6e..4f8dbdd 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,8 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_kakao( Some(""), // optional Some(""), // optional - Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/organization/delete-key.md b/docs/examples/proxy/create-smtp-rule.md similarity index 64% rename from docs/examples/organization/delete-key.md rename to docs/examples/proxy/create-smtp-rule.md index 34a1e1b..4f6c0e2 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Organization; +use appwrite::services::Proxy; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,12 +9,16 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let organization = Organization::new(&client); + let proxy = Proxy::new(&client); - organization.delete_key( - "" + let result = proxy.create_smtp_rule( + "example.com", + "", + Some("") // optional ).await?; + let _ = result; + Ok(()) } ``` diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 7e5d915..d837d4e 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let sites = Sites::new(&client); - let result = sites.delete_log( + sites.delete_log( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 409d88d..725a771 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::TablesDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index b5722c4..86e0b5c 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 36606d6..d3ebd3d 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let tables_db = TablesDB::new(&client); - let result = tables_db.delete_migration( + tables_db.delete_migration( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 92520ae..e1fe9bc 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.delete_rows( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index ba84a60..94e26a9 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.upsert_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index bb83298..14400af 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = teams.create_membership( "", - vec![], + vec!["editor".into()], Some("email@example.com"), // optional Some(""), // optional Some("+12065550100"), // optional diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index b635b14..6af98a5 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let teams = Teams::new(&client); - let result = teams.delete_installation( + teams.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 6c6d0d7..512671a 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = teams.update_membership( "", "", - vec![] + vec!["editor".into()] ).await?; let _ = result; diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 00922e3..9305ebb 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = users.update_labels( "", - vec![] + vec!["subscriber".into()] ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index 1010288..f539c40 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - 1, + 4, Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index d2aff1f..b8c30b6 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index 02d30e2..f686c4e 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::VectorsDBIndexType::HnswEuclidean, - vec![], + vec!["embeddings".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index cc1aaca..bc8db2b 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_operations( "", - Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"name":"Walter O'Brien"}})]) // optional + Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}}})]) // optional ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index a69a6a7..fc80819 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 86309ba..4256276 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - Some(1), // optional + Some(4), // optional Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index c556118..5f120e9 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index a14a6c1..2862ee9 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "https://example.com/webhook", "", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 73d636d..407ea25 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "", "https://example.com/webhook", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/src/client.rs b/src/client.rs index 946094f..50bb70c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -59,6 +59,12 @@ impl Default for UploadOptions { } } +#[derive(Debug, Clone, Copy)] +enum ResponseFormat { + Json, + Text, +} + /// Appwrite client for making API requests #[derive(Debug, Clone)] pub struct Client { @@ -91,11 +97,11 @@ impl Client { /// Create a new Appwrite client pub fn new() -> Self { let mut headers = HeaderMap::new(); - headers.insert("X-Appwrite-Response-Format", "2.0.0".parse().unwrap()); + headers.insert("X-Appwrite-Response-Format", "2.5.0".parse().unwrap()); headers.insert( "user-agent", format!( - "AppwriteRustSDK/0.19.0 ({}; {})", + "AppwriteRustSDK/0.20.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH ) @@ -105,7 +111,7 @@ impl Client { headers.insert("x-sdk-name", "Rust".parse().unwrap()); headers.insert("x-sdk-platform", "server".parse().unwrap()); headers.insert("x-sdk-language", "rust".parse().unwrap()); - headers.insert("x-sdk-version", "0.19.0".parse().unwrap()); + headers.insert("x-sdk-version", "0.20.0".parse().unwrap()); let config = Config { endpoint: "https://cloud.appwrite.io/v1".to_string(), @@ -289,21 +295,6 @@ impl Client { self.clone() } - /// Set DevKey - /// - /// Your secret dev API key - pub fn set_dev_key>(&self, value: S) -> Self { - let value = value.into(); - self.state.rcu(|state| { - let mut next = (**state).clone(); - next.config - .headers - .insert("x-appwrite-dev-key", value.clone().parse().unwrap()); - Arc::new(next) - }); - self.clone() - } - /// Set Cookie /// /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -554,36 +545,27 @@ impl Client { headers: Option>, params: Option>, ) -> Result { - let response = self.request(method, path, headers, params).await?; - self.handle_response(response).await - } - - /// Make an API call that returns a plain-text body as a UTF-8 string - pub async fn call_text( - &self, - method: Method, - path: &str, - headers: Option>, - params: Option>, - ) -> Result { - let response = self.request(method, path, headers, params).await?; - if response.status().is_success() { - return Ok(response.text().await?); - } - self.handle_response::(response) + self.send(method, path, headers, params, ResponseFormat::Json) .await - .map(|_| String::new()) } - async fn request( + async fn send( &self, method: Method, path: &str, headers: Option>, params: Option>, - ) -> Result { + format: ResponseFormat, + ) -> Result { let state = self.state.load_full(); let url = format!("{}{}", state.config.endpoint, path); + let is_multipart = method != Method::GET + && headers.as_ref().is_some_and(|headers| { + headers.iter().any(|(key, value)| { + key.eq_ignore_ascii_case("content-type") + && value.eq_ignore_ascii_case("multipart/form-data") + }) + }); let mut request_builder; if let Some(params) = params { @@ -600,21 +582,36 @@ impl Client { request_builder = state.http.request(method.clone(), url_with_params); } else { request_builder = state.http.request(method.clone(), &url); - request_builder = request_builder.json(¶ms); + if is_multipart { + let mut form = multipart::Form::new(); + for (key, value) in Self::flatten_multipart_params(¶ms, "") { + form = form.text(key, value); + } + request_builder = request_builder.multipart(form); + } else { + request_builder = request_builder.json(¶ms); + } } } else { request_builder = state.http.request(method.clone(), &url); } - request_builder = request_builder.headers(state.config.headers.clone()); + let mut default_headers = state.config.headers.clone(); + if is_multipart { + default_headers.remove("content-type"); + } + request_builder = request_builder.headers(default_headers); if let Some(custom_headers) = headers { for (key, value) in custom_headers { - request_builder = request_builder.header(key, value); + if !is_multipart || !key.eq_ignore_ascii_case("content-type") { + request_builder = request_builder.header(key, value); + } } } - Ok(request_builder.send().await?) + let response = request_builder.send().await?; + self.handle_response(response, format).await } /// Make an API call that returns a location/redirect URL (for webAuth endpoints) @@ -801,7 +798,19 @@ impl Client { } } - /// Upload a file + /// Make an API call that returns a plain-text body as a UTF-8 string + pub async fn call_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: Option>, + ) -> Result { + self.send(method, path, headers, params, ResponseFormat::Text) + .await + } + + /// Upload a file with POST pub async fn file_upload( &self, path: &str, @@ -824,7 +833,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method - #[allow(clippy::too_many_arguments)] pub async fn upload( &self, method: Method, @@ -851,7 +859,69 @@ impl Client { .await } - /// Upload a file with progress callback + /// Upload a file in one request whatever the configured chunk size, for + /// endpoints that do not accept chunked uploads + pub async fn single_upload( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) + .await + } + + /// Upload a file with POST and return the plain-text response body + pub async fn file_upload_text( + &self, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + self.upload_text(Method::POST, path, headers, params, param_name, input_file) + .await + } + + /// Upload a file with the endpoint's HTTP method and return the plain-text response body + pub async fn upload_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Text, + ) + .await + } + + /// Upload a file with POST and a progress callback pub async fn file_upload_with_progress( &self, path: &str, @@ -877,7 +947,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method and a progress callback - #[allow(clippy::too_many_arguments)] pub async fn upload_with_progress( &self, method: Method, @@ -902,7 +971,15 @@ impl Client { let url = format!("{}{}", state.config.endpoint, path); let result = self - .single_file_upload(method, &url, headers, params, param_name, &input_file) + .single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) .await?; if let Some(callback) = &options.on_progress { @@ -929,22 +1006,6 @@ impl Client { .await } - /// Upload a file in one request, whatever the configured chunk size, for - /// endpoints that do not accept chunked uploads - pub(crate) async fn single_upload( - &self, - method: Method, - path: &str, - headers: Option>, - params: HashMap, - param_name: &str, - input_file: InputFile, - ) -> Result { - let url = format!("{}{}", self.state.load_full().config.endpoint, path); - self.single_file_upload(method, &url, headers, params, param_name, &input_file) - .await - } - async fn single_file_upload( &self, method: Method, @@ -953,6 +1014,7 @@ impl Client { params: HashMap, param_name: &str, input_file: &InputFile, + format: ResponseFormat, ) -> Result { let state = self.state.load_full(); let mut form = multipart::Form::new(); @@ -997,10 +1059,9 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, format).await } - #[allow(clippy::too_many_arguments)] async fn chunked_file_upload_with_progress( &self, method: Method, @@ -1099,6 +1160,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1106,7 +1168,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1160,6 +1221,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1167,7 +1229,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1279,10 +1340,14 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, ResponseFormat::Json).await } - async fn handle_response(&self, response: Response) -> Result { + async fn handle_response( + &self, + response: Response, + format: ResponseFormat, + ) -> Result { let status = response.status(); let content_type = response .headers() @@ -1295,6 +1360,19 @@ impl Client { if status.is_success() { let bytes = response.bytes().await?; + if let ResponseFormat::Text = format { + let text = String::from_utf8(bytes.to_vec()).map_err(|e| { + AppwriteError::new( + 0, + format!("Invalid UTF-8 response: {}", e), + None, + String::from_utf8_lossy(e.as_bytes()).to_string(), + ) + })?; + + return Ok(serde_json::from_value(Value::String(text))?); + } + if !content_type.is_empty() && !content_type.starts_with("application/json") && !bytes.is_empty() @@ -1350,6 +1428,7 @@ impl Client { #[cfg(test)] mod tests { use super::*; + use crate::query::Query; #[test] fn test_client_creation() { @@ -1366,4 +1445,60 @@ mod tests { assert_eq!(client.endpoint(), "https://custom.example.com/v1"); } + + async fn mock_server() -> wiremock::MockServer { + let server = wiremock::MockServer::start().await; + wiremock::Mock::given(wiremock::matchers::any()) + .respond_with(wiremock::ResponseTemplate::new(200).set_body_json(serde_json::json!({}))) + .mount(&server) + .await; + server + } + + fn params() -> HashMap { + HashMap::from([ + ("values".to_string(), serde_json::json!([["a", "b"]])), + ( + "queries".to_string(), + serde_json::json!(Query::builder().limit(1)), + ), + ]) + } + + #[tokio::test] + async fn json_body_keeps_nested_string_arrays() { + let server = mock_server().await; + let client = Client::new().set_endpoint(server.uri()); + let headers = HashMap::from([("content-type".to_string(), "application/json".to_string())]); + + let _: Value = client + .call(Method::POST, "/", Some(headers), Some(params())) + .await + .unwrap(); + + let requests = server.received_requests().await.unwrap(); + let body: Value = serde_json::from_slice(&requests[0].body).unwrap(); + assert_eq!(body["values"], serde_json::json!([["a", "b"]])); + assert_eq!( + body["queries"], + serde_json::json!([Query::limit(1).to_string()]) + ); + } + + #[tokio::test] + async fn query_string_keeps_nested_string_arrays() { + let server = mock_server().await; + let client = Client::new().set_endpoint(server.uri()); + + let _: Value = client + .call(Method::GET, "/", None, Some(params())) + .await + .unwrap(); + + let requests = server.received_requests().await.unwrap(); + let pairs: Vec<(String, String)> = requests[0].url.query_pairs().into_owned().collect(); + assert!(pairs.contains(&("values[]".to_string(), "[\"a\",\"b\"]".to_string()))); + assert!(pairs.contains(&("queries[]".to_string(), Query::limit(1).to_string()))); + assert_eq!(pairs.len(), 2); + } } diff --git a/src/enums/billing_plan_group.rs b/src/enums/billing_plan_group.rs index 9557243..e8b9ed3 100644 --- a/src/enums/billing_plan_group.rs +++ b/src/enums/billing_plan_group.rs @@ -2,10 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum BillingPlanGroup { - #[serde(rename = "starter")] - #[default] - Starter, #[serde(rename = "free")] + #[default] Free, #[serde(rename = "start")] Start, @@ -19,7 +17,6 @@ impl BillingPlanGroup { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { - BillingPlanGroup::Starter => "starter", BillingPlanGroup::Free => "free", BillingPlanGroup::Start => "start", BillingPlanGroup::Pro => "pro", diff --git a/src/enums/execution_method.rs b/src/enums/execution_method.rs index 6764169..5dc4639 100644 --- a/src/enums/execution_method.rs +++ b/src/enums/execution_method.rs @@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ExecutionMethod { #[serde(rename = "GET")] - #[default] GET, #[serde(rename = "POST")] + #[default] POST, #[serde(rename = "PUT")] PUT, diff --git a/src/enums/execution_trigger.rs b/src/enums/execution_trigger.rs index 46fb2cd..201e671 100644 --- a/src/enums/execution_trigger.rs +++ b/src/enums/execution_trigger.rs @@ -9,6 +9,8 @@ pub enum ExecutionTrigger { Schedule, #[serde(rename = "event")] Event, + #[serde(rename = "email")] + Email, } impl ExecutionTrigger { @@ -18,6 +20,7 @@ impl ExecutionTrigger { ExecutionTrigger::Http => "http", ExecutionTrigger::Schedule => "schedule", ExecutionTrigger::Event => "event", + ExecutionTrigger::Email => "email", } } } diff --git a/src/enums/image_gravity.rs b/src/enums/image_gravity.rs index 202aa5e..5114a01 100644 --- a/src/enums/image_gravity.rs +++ b/src/enums/image_gravity.rs @@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ImageGravity { + #[serde(rename = "auto")] + Auto, #[serde(rename = "center")] #[default] Center, @@ -21,14 +23,13 @@ pub enum ImageGravity { Bottom, #[serde(rename = "bottom-right")] BottomRight, - #[serde(rename = "auto")] - Auto, } impl ImageGravity { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { + ImageGravity::Auto => "auto", ImageGravity::Center => "center", ImageGravity::TopLeft => "top-left", ImageGravity::Top => "top", @@ -38,7 +39,6 @@ impl ImageGravity { ImageGravity::BottomLeft => "bottom-left", ImageGravity::Bottom => "bottom", ImageGravity::BottomRight => "bottom-right", - ImageGravity::Auto => "auto", } } } diff --git a/src/enums/mod.rs b/src/enums/mod.rs index 91c4db1..607046f 100644 --- a/src/enums/mod.rs +++ b/src/enums/mod.rs @@ -54,8 +54,6 @@ pub mod message_priority; pub use message_priority::MessagePriority; pub mod smtp_encryption; pub use smtp_encryption::SmtpEncryption; -pub mod organization_key_scopes; -pub use organization_key_scopes::OrganizationKeyScopes; pub mod region; pub use region::Region; pub mod project_auth_method_id; @@ -162,6 +160,8 @@ pub mod proxy_rule_deployment_resource_type; pub use proxy_rule_deployment_resource_type::ProxyRuleDeploymentResourceType; pub mod proxy_rule_status; pub use proxy_rule_status::ProxyRuleStatus; +pub mod proxy_rule_protocol; +pub use proxy_rule_protocol::ProxyRuleProtocol; pub mod message_status; pub use message_status::MessageStatus; pub mod billing_plan_group; diff --git a/src/enums/organization_key_scopes.rs b/src/enums/organization_key_scopes.rs deleted file mode 100644 index 7844c9b..0000000 --- a/src/enums/organization_key_scopes.rs +++ /dev/null @@ -1,72 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] -pub enum OrganizationKeyScopes { - #[serde(rename = "projects.read")] - #[default] - ProjectsRead, - #[serde(rename = "projects.write")] - ProjectsWrite, - #[serde(rename = "devKeys.read")] - DevKeysRead, - #[serde(rename = "devKeys.write")] - DevKeysWrite, - #[serde(rename = "organization.keys.read")] - OrganizationKeysRead, - #[serde(rename = "organization.keys.write")] - OrganizationKeysWrite, - #[serde(rename = "organization.installations.read")] - OrganizationInstallationsRead, - #[serde(rename = "organization.installations.write")] - OrganizationInstallationsWrite, - #[serde(rename = "organization.memberships.read")] - OrganizationMembershipsRead, - #[serde(rename = "organization.memberships.write")] - OrganizationMembershipsWrite, - #[serde(rename = "organization.read")] - OrganizationRead, - #[serde(rename = "organization.write")] - OrganizationWrite, - #[serde(rename = "domains.read")] - DomainsRead, - #[serde(rename = "domains.write")] - DomainsWrite, - #[serde(rename = "keys.read")] - KeysRead, - #[serde(rename = "keys.write")] - KeysWrite, -} - -impl OrganizationKeyScopes { - /// Get the string value of the enum - pub fn as_str(&self) -> &str { - match self { - OrganizationKeyScopes::ProjectsRead => "projects.read", - OrganizationKeyScopes::ProjectsWrite => "projects.write", - OrganizationKeyScopes::DevKeysRead => "devKeys.read", - OrganizationKeyScopes::DevKeysWrite => "devKeys.write", - OrganizationKeyScopes::OrganizationKeysRead => "organization.keys.read", - OrganizationKeyScopes::OrganizationKeysWrite => "organization.keys.write", - OrganizationKeyScopes::OrganizationInstallationsRead => { - "organization.installations.read" - } - OrganizationKeyScopes::OrganizationInstallationsWrite => { - "organization.installations.write" - } - OrganizationKeyScopes::OrganizationMembershipsRead => "organization.memberships.read", - OrganizationKeyScopes::OrganizationMembershipsWrite => "organization.memberships.write", - OrganizationKeyScopes::OrganizationRead => "organization.read", - OrganizationKeyScopes::OrganizationWrite => "organization.write", - OrganizationKeyScopes::DomainsRead => "domains.read", - OrganizationKeyScopes::DomainsWrite => "domains.write", - OrganizationKeyScopes::KeysRead => "keys.read", - OrganizationKeyScopes::KeysWrite => "keys.write", - } - } -} - -impl std::fmt::Display for OrganizationKeyScopes { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.as_str()) - } -} diff --git a/src/enums/proxy_rule_protocol.rs b/src/enums/proxy_rule_protocol.rs new file mode 100644 index 0000000..b5ac0d2 --- /dev/null +++ b/src/enums/proxy_rule_protocol.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProxyRuleProtocol { + #[serde(rename = "http")] + #[default] + Http, + #[serde(rename = "smtp")] + Smtp, +} + +impl ProxyRuleProtocol { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProxyRuleProtocol::Http => "http", + ProxyRuleProtocol::Smtp => "smtp", + } + } +} + +impl std::fmt::Display for ProxyRuleProtocol { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/lib.rs b/src/lib.rs index 25914d9..b9f7ed2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```toml //! [dependencies] -//! appwrite = "0.19.0" +//! appwrite = "0.20.0" //! ``` //! //! ## Usage @@ -41,6 +41,7 @@ pub mod operator; pub mod permission; pub mod query; pub mod role; +pub mod topic; // Re-export commonly used types pub use client::Client; @@ -51,7 +52,7 @@ pub use input_file::InputFile; pub type Result = std::result::Result; /// SDK version -pub const VERSION: &str = "0.19.0"; +pub const VERSION: &str = "0.20.0"; /// SDK name pub const SDK_NAME: &str = "Rust"; diff --git a/src/models/activity_event.rs b/src/models/activity_event.rs index 5590142..b488871 100644 --- a/src/models/activity_event.rs +++ b/src/models/activity_event.rs @@ -8,93 +8,238 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEvent { /// Event ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Actor type. #[serde(rename = "actorType")] + #[serde(default = "default_actor_type")] pub actor_type: String, /// Actor ID. #[serde(rename = "actorId")] + #[serde(default = "default_actor_id")] pub actor_id: String, /// Actor Email. #[serde(rename = "actorEmail")] + #[serde(default = "default_actor_email")] pub actor_email: String, /// Actor Name. #[serde(rename = "actorName")] + #[serde(default = "default_actor_name")] pub actor_name: String, /// Resource parent. #[serde(rename = "resourceParent")] + #[serde(default = "default_resource_parent")] pub resource_parent: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource. #[serde(rename = "resource")] + #[serde(default = "default_resource")] pub resource: String, /// Event name. #[serde(rename = "event")] + #[serde(default = "default_event")] pub event: String, /// User agent. #[serde(rename = "userAgent")] + #[serde(default = "default_user_agent")] pub user_agent: String, /// IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// API mode when event triggered. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Location. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// City name. #[serde(rename = "city")] + #[serde(default = "default_city")] pub city: String, /// Region/state chain. #[serde(rename = "subdivisions")] + #[serde(default = "default_subdivisions")] pub subdivisions: String, /// Internet service provider. #[serde(rename = "isp")] + #[serde(default = "default_isp")] pub isp: String, /// Autonomous System Number (ASN). #[serde(rename = "autonomousSystemNumber")] + #[serde(default = "default_autonomous_system_number")] pub autonomous_system_number: String, /// Organization that owns the ASN. #[serde(rename = "autonomousSystemOrganization")] + #[serde(default = "default_autonomous_system_organization")] pub autonomous_system_organization: String, /// Connection type (e.g. cable, cellular, corporate). #[serde(rename = "connectionType")] + #[serde(default = "default_connection_type")] pub connection_type: String, /// User type (e.g. residential, business, hosting). #[serde(rename = "connectionUsageType")] + #[serde(default = "default_connection_usage_type")] pub connection_usage_type: String, /// Registered organization of the IP. #[serde(rename = "connectionOrganization")] + #[serde(default = "default_connection_organization")] pub connection_organization: String, /// Log creation date in ISO 8601 format. #[serde(rename = "time")] + #[serde(default = "default_time")] pub time: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Hostname. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Name of the SDK that triggered the event. #[serde(rename = "sdk")] + #[serde(default = "default_sdk")] pub sdk: String, /// Version of the SDK that triggered the event. #[serde(rename = "sdkVersion")] + #[serde(default = "default_sdk_version")] pub sdk_version: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_actor_type() -> String { + "".to_string() +} + +fn default_actor_id() -> String { + "".to_string() +} + +fn default_actor_email() -> String { + "".to_string() +} + +fn default_actor_name() -> String { + "".to_string() +} + +fn default_resource_parent() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource() -> String { + "".to_string() +} + +fn default_event() -> String { + "".to_string() +} + +fn default_user_agent() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_mode() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_city() -> String { + "".to_string() +} + +fn default_subdivisions() -> String { + "".to_string() +} + +fn default_isp() -> String { + "".to_string() +} + +fn default_autonomous_system_number() -> String { + "".to_string() +} + +fn default_autonomous_system_organization() -> String { + "".to_string() +} + +fn default_connection_type() -> String { + "".to_string() +} + +fn default_connection_usage_type() -> String { + "".to_string() +} + +fn default_connection_organization() -> String { + "".to_string() +} + +fn default_time() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_sdk() -> String { + "".to_string() +} + +fn default_sdk_version() -> String { + "".to_string() +} + impl ActivityEvent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/activity_event_list.rs b/src/models/activity_event_list.rs index a83d557..ff7cf56 100644 --- a/src/models/activity_event_list.rs +++ b/src/models/activity_event_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEventList { /// Total number of events that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ActivityEventList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/additional_resource.rs b/src/models/additional_resource.rs index bf02523..8f5d252 100644 --- a/src/models/additional_resource.rs +++ b/src/models/additional_resource.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct AdditionalResource { /// Resource name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Resource unit #[serde(rename = "unit")] + #[serde(default = "default_unit")] pub unit: String, /// Price currency #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_unit() -> String { + "".to_string() +} + +fn default_currency() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl AdditionalResource { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/algo_argon2.rs b/src/models/algo_argon2.rs index c4e4c7e..490a220 100644 --- a/src/models/algo_argon2.rs +++ b/src/models/algo_argon2.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoArgon2 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Memory used to compute hash. #[serde(rename = "memoryCost")] + #[serde(default = "default_memory_cost")] pub memory_cost: i64, /// Amount of time consumed to compute hash #[serde(rename = "timeCost")] + #[serde(default = "default_time_cost")] pub time_cost: i64, /// Number of threads used to compute hash. #[serde(rename = "threads")] + #[serde(default = "default_threads")] pub threads: i64, } +fn default_type() -> String { + "argon2".to_string() +} + +fn default_memory_cost() -> i64 { + 0 +} + +fn default_time_cost() -> i64 { + 0 +} + +fn default_threads() -> i64 { + 0 +} + impl AlgoArgon2 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_bcrypt.rs b/src/models/algo_bcrypt.rs index acbd333..93c307f 100644 --- a/src/models/algo_bcrypt.rs +++ b/src/models/algo_bcrypt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoBcrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "bcrypt".to_string() +} + impl AlgoBcrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_md5.rs b/src/models/algo_md5.rs index babd088..3f75ba8 100644 --- a/src/models/algo_md5.rs +++ b/src/models/algo_md5.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoMd5 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "md5".to_string() +} + impl AlgoMd5 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_phpass.rs b/src/models/algo_phpass.rs index 8227738..0a9f876 100644 --- a/src/models/algo_phpass.rs +++ b/src/models/algo_phpass.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoPhpass { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "phpass".to_string() +} + impl AlgoPhpass { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt.rs b/src/models/algo_scrypt.rs index 86a424a..18c4bce 100644 --- a/src/models/algo_scrypt.rs +++ b/src/models/algo_scrypt.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// CPU complexity of computed hash. #[serde(rename = "costCpu")] + #[serde(default = "default_cost_cpu")] pub cost_cpu: i64, /// Memory complexity of computed hash. #[serde(rename = "costMemory")] + #[serde(default = "default_cost_memory")] pub cost_memory: i64, /// Parallelization of computed hash. #[serde(rename = "costParallel")] + #[serde(default = "default_cost_parallel")] pub cost_parallel: i64, /// Length used to compute hash. #[serde(rename = "length")] + #[serde(default = "default_length")] pub length: i64, } +fn default_type() -> String { + "scrypt".to_string() +} + +fn default_cost_cpu() -> i64 { + 8 +} + +fn default_cost_memory() -> i64 { + 14 +} + +fn default_cost_parallel() -> i64 { + 1 +} + +fn default_length() -> i64 { + 64 +} + impl AlgoScrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt_modified.rs b/src/models/algo_scrypt_modified.rs index 3722ebd..35cd10c 100644 --- a/src/models/algo_scrypt_modified.rs +++ b/src/models/algo_scrypt_modified.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScryptModified { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Salt used to compute hash. #[serde(rename = "salt")] + #[serde(default = "default_salt")] pub salt: String, /// Separator used to compute hash. #[serde(rename = "saltSeparator")] + #[serde(default = "default_salt_separator")] pub salt_separator: String, /// Key used to compute hash. #[serde(rename = "signerKey")] + #[serde(default = "default_signer_key")] pub signer_key: String, } +fn default_type() -> String { + "scryptMod".to_string() +} + +fn default_salt() -> String { + "".to_string() +} + +fn default_salt_separator() -> String { + "".to_string() +} + +fn default_signer_key() -> String { + "".to_string() +} + impl AlgoScryptModified { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_sha.rs b/src/models/algo_sha.rs index e8aa8fb..f3af46d 100644 --- a/src/models/algo_sha.rs +++ b/src/models/algo_sha.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoSha { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "sha".to_string() +} + impl AlgoSha { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/app.rs b/src/models/app.rs index 35791b2..3ed9196 100644 --- a/src/models/app.rs +++ b/src/models/app.rs @@ -8,95 +8,225 @@ use serde::{Deserialize, Serialize}; pub struct App { /// App ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Application description shown to users during OAuth2 consent. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Application homepage URL shown to users during OAuth2 consent. #[serde(rename = "clientUri")] + #[serde(default = "default_client_uri")] pub client_uri: String, /// Application logo URL shown to users during OAuth2 consent. #[serde(rename = "logoUri")] + #[serde(default = "default_logo_uri")] pub logo_uri: String, /// Application privacy policy URL shown to users during OAuth2 consent. #[serde(rename = "privacyPolicyUrl")] + #[serde(default = "default_privacy_policy_url")] pub privacy_policy_url: String, /// Application terms of service URL shown to users during OAuth2 consent. #[serde(rename = "termsUrl")] + #[serde(default = "default_terms_url")] pub terms_url: String, /// Application support or security contact emails. #[serde(rename = "contacts")] + #[serde(default = "default_contacts")] pub contacts: Vec, /// Application tagline shown to users during OAuth2 consent. #[serde(rename = "tagline")] + #[serde(default = "default_tagline")] pub tagline: String, /// Application tags shown to users during OAuth2 consent. #[serde(rename = "tags")] + #[serde(default = "default_tags")] pub tags: Vec, /// Application labels. Read-only for clients; only a server SDK using a /// project API key can update them. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Application image URLs shown to users during OAuth2 consent. #[serde(rename = "images")] + #[serde(default = "default_images")] pub images: Vec, /// Application support URL shown to users during OAuth2 consent. #[serde(rename = "supportUrl")] + #[serde(default = "default_support_url")] pub support_url: String, /// Application data deletion URL shown to users during OAuth2 consent. #[serde(rename = "dataDeletionUrl")] + #[serde(default = "default_data_deletion_url")] pub data_deletion_url: String, /// List of authorized redirect URIs. These URIs can be used to redirect users /// after they authenticate. #[serde(rename = "redirectUris")] + #[serde(default = "default_redirect_uris")] pub redirect_uris: Vec, /// List of authorized post-logout redirect URIs for OpenID Connect /// RP-Initiated Logout. The logout endpoint only redirects users to URIs in /// this list after ending their session. #[serde(rename = "postLogoutRedirectUris")] + #[serde(default = "default_post_logout_redirect_uris")] pub post_logout_redirect_uris: Vec, /// Whether the app is enabled or not. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot /// keep a client secret (PKCE required); `confidential` for server-side /// clients that authenticate with a client secret. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Whether this client may use the OAuth2 Device Authorization Grant (RFC /// 8628). #[serde(rename = "deviceFlow")] + #[serde(default = "default_device_flow")] pub device_flow: bool, /// ID of team that owns the application, if owned by team. Otherwise, user ID /// will be used. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// ID of user who owns the application, if owned by user. Otherwise, team ID /// will be used. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Scopes the application requests when installed on a team. /// Organization-level and project-level scopes only. #[serde(rename = "installationScopes")] + #[serde(default = "default_installation_scopes")] pub installation_scopes: Vec, /// URL users are redirected to after creating or updating an installation of /// this application. Empty for no redirect. #[serde(rename = "installationRedirectUrl")] + #[serde(default = "default_installation_redirect_url")] pub installation_redirect_url: String, /// List of application secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_client_uri() -> String { + "".to_string() +} + +fn default_logo_uri() -> String { + "".to_string() +} + +fn default_privacy_policy_url() -> String { + "".to_string() +} + +fn default_terms_url() -> String { + "".to_string() +} + +fn default_contacts() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tagline() -> String { + "".to_string() +} + +fn default_tags() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_images() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_support_url() -> String { + "".to_string() +} + +fn default_data_deletion_url() -> String { + "".to_string() +} + +fn default_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_post_logout_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "confidential".to_string() +} + +fn default_device_flow() -> bool { + false +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_installation_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_installation_redirect_url() -> String { + "".to_string() +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl App { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation.rs b/src/models/app_installation.rs index 7ad4193..970ba93 100644 --- a/src/models/app_installation.rs +++ b/src/models/app_installation.rs @@ -8,34 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallation { /// Installation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Installation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Installation update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the installed application. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// ID of the team the application is installed on. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Scopes granted to the application. Snapshot of the application's /// installation scopes taken when the installation was created or last /// updated. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Authorization details granted to the application. Rich authorization /// request (RFC 9396) style entries; the Appwrite Console stores authorized /// project IDs here. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: Vec, /// ID of the user who created the installation. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the installation. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time an access token was last issued for the installation in ISO 8601 /// format. Null if never used. @@ -44,6 +53,42 @@ pub struct AppInstallation { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppInstallation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation_list.rs b/src/models/app_installation_list.rs index aa427f0..69c156a 100644 --- a/src/models/app_installation_list.rs +++ b/src/models/app_installation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallationList { /// Total number of installations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of installations. #[serde(rename = "installations")] + #[serde(default = "default_installations")] pub installations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_installations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppInstallationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_key.rs b/src/models/app_key.rs index cbfbbd0..4902670 100644 --- a/src/models/app_key.rs +++ b/src/models/app_key.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct AppKey { /// App key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App key creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App key update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this app key belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// App key secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the app key secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the app key. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the app key. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the app key was last used for authentication in ISO 8601 format. Null /// if never used. @@ -37,6 +45,38 @@ pub struct AppKey { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_key_list.rs b/src/models/app_key_list.rs index 232fa6f..d9ca8bb 100644 --- a/src/models/app_key_list.rs +++ b/src/models/app_key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppKeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppKeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_scope.rs b/src/models/app_scope.rs index 7f14082..fcdf744 100644 --- a/src/models/app_scope.rs +++ b/src/models/app_scope.rs @@ -8,23 +8,48 @@ use serde::{Deserialize, Serialize}; pub struct AppScope { /// Scope value as requested by apps. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Human-readable description of what the scope grants. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// What the scope grants access to. One of `account`, `project`, or /// `organization`. Only `project` and `organization` scopes are installable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Scope category, used to group scopes on consent and installation screens. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, /// Whether the scope is deprecated. Deprecated scopes can still be requested /// but should not be offered for new grants. #[serde(rename = "deprecated")] + #[serde(default = "default_deprecated")] pub deprecated: bool, } +fn default_value() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + +fn default_deprecated() -> bool { + false +} + impl AppScope { /// Get value pub fn value(&self) -> &String { diff --git a/src/models/app_scope_list.rs b/src/models/app_scope_list.rs index 0d93b62..cd03802 100644 --- a/src/models/app_scope_list.rs +++ b/src/models/app_scope_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppScopeList { /// Total number of scopes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppScopeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret.rs b/src/models/app_secret.rs index a32282b..43fd6cd 100644 --- a/src/models/app_secret.rs +++ b/src/models/app_secret.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecret { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Always empty. The application client secret is returned only once, in the /// response of the createSecret method. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecret { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_secret_list.rs b/src/models/app_secret_list.rs index f9df34d..23dcef0 100644 --- a/src/models/app_secret_list.rs +++ b/src/models/app_secret_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretList { /// Total number of secrets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppSecretList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret_plaintext.rs b/src/models/app_secret_plaintext.rs index 4c7a292..486d526 100644 --- a/src/models/app_secret_plaintext.rs +++ b/src/models/app_secret_plaintext.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretPlaintext { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Application client secret. Returned only when the secret is created; /// subsequent reads always return an empty value. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecretPlaintext { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecretPlaintext { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/apps_list.rs b/src/models/apps_list.rs index 6f31208..b8c106d 100644 --- a/src/models/apps_list.rs +++ b/src/models/apps_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppsList { /// Total number of apps that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of apps. #[serde(rename = "apps")] + #[serde(default = "default_apps")] pub apps: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_apps() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppsList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_bigint.rs b/src/models/attribute_bigint.rs index 7dffebc..9f298a7 100644 --- a/src/models/attribute_bigint.rs +++ b/src/models/attribute_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBigint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBigint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBigint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_boolean.rs b/src/models/attribute_boolean.rs index e6ddcc3..e08baa3 100644 --- a/src/models/attribute_boolean.rs +++ b/src/models/attribute_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBoolean { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBoolean { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_datetime.rs b/src/models/attribute_datetime.rs index beacd6d..79621c2 100644 --- a/src/models/attribute_datetime.rs +++ b/src/models/attribute_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeDatetime { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeDatetime { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct AttributeDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_email.rs b/src/models/attribute_email.rs index 2f172f7..76dcae3 100644 --- a/src/models/attribute_email.rs +++ b/src/models/attribute_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEmail { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEmail { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeEmail { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl AttributeEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_enum.rs b/src/models/attribute_enum.rs index f78d0eb..620db3a 100644 --- a/src/models/attribute_enum.rs +++ b/src/models/attribute_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEnum { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEnum { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct AttributeEnum { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -46,6 +54,38 @@ pub struct AttributeEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl AttributeEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_float.rs b/src/models/attribute_float.rs index 49cda73..a8467e7 100644 --- a/src/models/attribute_float.rs +++ b/src/models/attribute_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeFloat { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeFloat { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeFloat { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_integer.rs b/src/models/attribute_integer.rs index 39cad56..abb02d0 100644 --- a/src/models/attribute_integer.rs +++ b/src/models/attribute_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeInteger { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeInteger { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeInteger { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_ip.rs b/src/models/attribute_ip.rs index 2328c38..85c4070 100644 --- a/src/models/attribute_ip.rs +++ b/src/models/attribute_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeIp { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeIp { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeIp { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl AttributeIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_line.rs b/src/models/attribute_line.rs index 975994b..670484f 100644 --- a/src/models/attribute_line.rs +++ b/src/models/attribute_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLine { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLine { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLine { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_list.rs b/src/models/attribute_list.rs index d405e6d..73e9346 100644 --- a/src/models/attribute_list.rs +++ b/src/models/attribute_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AttributeList { /// Total number of attributes in the given collection. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AttributeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_longtext.rs b/src/models/attribute_longtext.rs index b613bf1..a45a044 100644 --- a/src/models/attribute_longtext.rs +++ b/src/models/attribute_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLongtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLongtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_mediumtext.rs b/src/models/attribute_mediumtext.rs index 98fcecd..18271f2 100644 --- a/src/models/attribute_mediumtext.rs +++ b/src/models/attribute_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeMediumtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeMediumtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_object.rs b/src/models/attribute_object.rs index 02515bf..ce3af14 100644 --- a/src/models/attribute_object.rs +++ b/src/models/attribute_object.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeObject { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeObject { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,38 @@ pub struct AttributeObject { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeObject { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_point.rs b/src/models/attribute_point.rs index 9ca02a2..d9284e1 100644 --- a/src/models/attribute_point.rs +++ b/src/models/attribute_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePoint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePoint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePoint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_polygon.rs b/src/models/attribute_polygon.rs index 3d39979..59a058b 100644 --- a/src/models/attribute_polygon.rs +++ b/src/models/attribute_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePolygon { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePolygon { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePolygon { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_relationship.rs b/src/models/attribute_relationship.rs index ce0efaf..17b1786 100644 --- a/src/models/attribute_relationship.rs +++ b/src/models/attribute_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeRelationship { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct AttributeRelationship { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related collection. #[serde(rename = "relatedCollection")] pub related_collection: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl AttributeRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_string.rs b/src/models/attribute_string.rs index 93dc8bc..eacad88 100644 --- a/src/models/attribute_string.rs +++ b/src/models/attribute_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeString { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeString { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeString { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_text.rs b/src/models/attribute_text.rs index 838d477..bf666ea 100644 --- a/src/models/attribute_text.rs +++ b/src/models/attribute_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeText { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeText { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeText { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_url.rs b/src/models/attribute_url.rs index 4dfc86c..2305191 100644 --- a/src/models/attribute_url.rs +++ b/src/models/attribute_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeUrl { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeUrl { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeUrl { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl AttributeUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_varchar.rs b/src/models/attribute_varchar.rs index 433fc29..a3277a9 100644 --- a/src/models/attribute_varchar.rs +++ b/src/models/attribute_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVarchar { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeVarchar { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_vector.rs b/src/models/attribute_vector.rs index 2472da9..79dc1c8 100644 --- a/src/models/attribute_vector.rs +++ b/src/models/attribute_vector.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVector { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVector { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,46 @@ pub struct AttributeVector { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Vector dimensions. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVector { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/backup_archive.rs b/src/models/backup_archive.rs index f4811a5..d64dce1 100644 --- a/src/models/backup_archive.rs +++ b/src/models/backup_archive.rs @@ -8,34 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchive { /// Archive ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Archive creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Archive update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Archive policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, - /// Archive size in bytes. + /// Archive size in bytes. Null until the size is known. #[serde(rename = "size")] - pub size: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, /// The status of the archive creation. Possible values: pending, processing, /// uploading, completed, failed, skipped. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The backup start time. Null until the backup starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this archive. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this archive. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this archive should backup a single /// resource. @@ -49,6 +59,38 @@ pub struct BackupArchive { pub resource_type: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchive { /// Get id pub fn id(&self) -> &String { @@ -70,9 +112,15 @@ impl BackupArchive { &self.policy_id } + /// Set size + pub fn set_size(mut self, size: i64) -> Self { + self.size = Some(size); + self + } + /// Get size - pub fn size(&self) -> &i64 { - &self.size + pub fn size(&self) -> Option<&i64> { + self.size.as_ref() } /// Get status @@ -80,9 +128,15 @@ impl BackupArchive { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -134,9 +188,7 @@ mod tests { let _ = _model.created_at(); let _ = _model.updated_at(); let _ = _model.policy_id(); - let _ = _model.size(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_archive_list.rs b/src/models/backup_archive_list.rs index 46af024..6c12aea 100644 --- a/src/models/backup_archive_list.rs +++ b/src/models/backup_archive_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchiveList { /// Total number of archives that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of archives. #[serde(rename = "archives")] + #[serde(default = "default_archives")] pub archives: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_archives() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchiveList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_policy.rs b/src/models/backup_policy.rs index 0ee8535..5c2c5a7 100644 --- a/src/models/backup_policy.rs +++ b/src/models/backup_policy.rs @@ -8,21 +8,27 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicy { /// Backup policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup policy name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Policy creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Policy update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this policy should backup a single /// resource. @@ -36,19 +42,63 @@ pub struct BackupPolicy { pub resource_type: Option, /// How many days to keep the backup before it will be automatically deleted. #[serde(rename = "retention")] + #[serde(default = "default_retention")] pub retention: i64, /// Policy backup schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Is this policy enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_retention() -> i64 { + 1 +} + +fn default_schedule() -> String { + "0 * * * *".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_enabled() -> bool { + false +} + impl BackupPolicy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/backup_policy_list.rs b/src/models/backup_policy_list.rs index 299f36b..60a4ad3 100644 --- a/src/models/backup_policy_list.rs +++ b/src/models/backup_policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicyList { /// Total number of policies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupPolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_restoration.rs b/src/models/backup_restoration.rs index 45931ed..2dc302b 100644 --- a/src/models/backup_restoration.rs +++ b/src/models/backup_restoration.rs @@ -8,38 +8,89 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Restoration update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Backup archive ID. #[serde(rename = "archiveId")] + #[serde(default = "default_archive_id")] pub archive_id: String, /// Backup policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// The status of the restoration. Possible values: pending, downloading, /// processing, completed, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The restoration start time. Null until the restoration starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, - /// Optional data in key-value object. + /// Restoration options as a key-value object. #[serde(rename = "options")] - pub options: String, + #[serde(default = "default_options")] + pub options: serde_json::Value, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_archive_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_options() -> serde_json::Value { + serde_json::json!({}) } impl BackupRestoration { @@ -73,9 +124,15 @@ impl BackupRestoration { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -94,7 +151,7 @@ impl BackupRestoration { } /// Get options - pub fn options(&self) -> &String { + pub fn options(&self) -> &serde_json::Value { &self.options } } @@ -112,7 +169,6 @@ mod tests { let _ = _model.archive_id(); let _ = _model.policy_id(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_restoration_list.rs b/src/models/backup_restoration_list.rs index 65c9ad3..33d4196 100644 --- a/src/models/backup_restoration_list.rs +++ b/src/models/backup_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/billing_plan.rs b/src/models/billing_plan.rs index 936f3d8..1e43f95 100644 --- a/src/models/billing_plan.rs +++ b/src/models/billing_plan.rs @@ -8,33 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlan { /// Plan ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Plan name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Plan description #[serde(rename = "desc")] + #[serde(default = "default_desc")] pub desc: String, /// Plan order #[serde(rename = "order")] + #[serde(default = "default_order")] pub order: i64, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Trial days #[serde(rename = "trial")] + #[serde(default = "default_trial")] pub trial: i64, /// Bandwidth #[serde(rename = "bandwidth")] + #[serde(default = "default_bandwidth")] pub bandwidth: i64, /// Storage #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Image Transformations #[serde(rename = "imageTransformations")] + #[serde(default = "default_image_transformations")] pub image_transformations: i64, /// Screenshots generated #[serde(rename = "screenshotsGenerated")] + #[serde(default = "default_screenshots_generated")] pub screenshots_generated: i64, /// Members #[serde(rename = "members")] @@ -42,77 +52,100 @@ pub struct BillingPlan { pub members: Option, /// Webhooks #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: i64, /// Maximum WAF rules per project #[serde(rename = "wafRules")] + #[serde(default = "default_waf_rules")] pub waf_rules: i64, /// Maximum environments per project. 0 when the plan does not offer /// environments. #[serde(rename = "environments")] - #[serde(skip_serializing_if = "Option::is_none")] - pub environments: Option, + #[serde(default = "default_environments")] + pub environments: i64, /// Projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: i64, /// Platforms #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: i64, /// Users #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: i64, /// Teams #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: i64, /// Databases #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: i64, /// Database reads per month #[serde(rename = "databasesReads")] + #[serde(default = "default_databases_reads")] pub databases_reads: i64, /// Database writes per month #[serde(rename = "databasesWrites")] + #[serde(default = "default_databases_writes")] pub databases_writes: i64, /// Database batch size limit #[serde(rename = "databasesBatchSize")] + #[serde(default = "default_databases_batch_size")] pub databases_batch_size: i64, /// Buckets #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: i64, /// File size #[serde(rename = "fileSize")] + #[serde(default = "default_file_size")] pub file_size: i64, /// Functions #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: i64, /// Sites #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: i64, /// Function executions #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: i64, /// Rolling max executions retained per function/site #[serde(rename = "executionsRetentionCount")] + #[serde(default = "default_executions_retention_count")] pub executions_retention_count: i64, /// GB hours for functions #[serde(rename = "GBHours")] + #[serde(default = "default_gb_hours")] pub gb_hours: i64, /// Realtime connections #[serde(rename = "realtime")] + #[serde(default = "default_realtime")] pub realtime: i64, /// Realtime messages #[serde(rename = "realtimeMessages")] + #[serde(default = "default_realtime_messages")] pub realtime_messages: i64, /// Messages per month #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: i64, /// Topics for messaging #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: i64, /// SMS authentications per month #[serde(rename = "authPhone")] + #[serde(default = "default_auth_phone")] pub auth_phone: i64, /// Custom domains #[serde(rename = "domains")] + #[serde(default = "default_domains")] pub domains: i64, /// Activity log days #[serde(rename = "activityLogs")] @@ -120,6 +153,7 @@ pub struct BillingPlan { pub activity_logs: Option, /// Usage history days #[serde(rename = "usageLogs")] + #[serde(default = "default_usage_logs")] pub usage_logs: i64, /// Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). #[serde(rename = "usageLogsIntervals")] @@ -134,30 +168,38 @@ pub struct BillingPlan { /// Number of days of console inactivity before a project is paused. 0 means /// pausing is disabled. #[serde(rename = "projectInactivityDays")] + #[serde(default = "default_project_inactivity_days")] pub project_inactivity_days: i64, /// Alert threshold percentage #[serde(rename = "alertLimit")] + #[serde(default = "default_alert_limit")] pub alert_limit: i64, - /// Additional resources + /// Additional resources. Null when the plan does not support usage billing. #[serde(rename = "usage")] - pub usage: crate::models::UsageBillingPlan, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage: Option, /// Addons #[serde(rename = "addons")] pub addons: crate::models::BillingPlanAddon, /// Budget cap enabled or disabled. #[serde(rename = "budgetCapEnabled")] + #[serde(default = "default_budget_cap_enabled")] pub budget_cap_enabled: bool, /// Custom SMTP #[serde(rename = "customSmtp")] + #[serde(default = "default_custom_smtp")] pub custom_smtp: bool, /// Appwrite branding in email #[serde(rename = "emailBranding")] + #[serde(default = "default_email_branding")] pub email_branding: bool, /// Does plan require payment method #[serde(rename = "requiresPaymentMethod")] + #[serde(default = "default_requires_payment_method")] pub requires_payment_method: bool, /// Does plan require billing address #[serde(rename = "requiresBillingAddress")] + #[serde(default = "default_requires_billing_address")] pub requires_billing_address: bool, /// ISO country codes eligible for this regional plan. Empty means no /// restriction. @@ -166,42 +208,55 @@ pub struct BillingPlan { pub eligible_countries: Option>, /// Is the billing plan available #[serde(rename = "isAvailable")] + #[serde(default = "default_is_available")] pub is_available: bool, /// Can user change the plan themselves #[serde(rename = "selfService")] + #[serde(default = "default_self_service")] pub self_service: bool, /// Does plan enable premium support #[serde(rename = "premiumSupport")] + #[serde(default = "default_premium_support")] pub premium_support: bool, /// Does plan support budget cap #[serde(rename = "budgeting")] + #[serde(default = "default_budgeting")] pub budgeting: bool, /// Does plan support mock numbers #[serde(rename = "supportsMockNumbers")] + #[serde(default = "default_supports_mock_numbers")] pub supports_mock_numbers: bool, /// Does plan support organization roles #[serde(rename = "supportsOrganizationRoles")] + #[serde(default = "default_supports_organization_roles")] pub supports_organization_roles: bool, /// Does plan support credit #[serde(rename = "supportsCredits")] + #[serde(default = "default_supports_credits")] pub supports_credits: bool, /// Does plan support dedicated databases. #[serde(rename = "supportsDedicatedDatabases")] + #[serde(default = "default_supports_dedicated_databases")] pub supports_dedicated_databases: bool, /// Does plan support blocking disposable email addresses. #[serde(rename = "supportsDisposableEmailValidation")] + #[serde(default = "default_supports_disposable_email_validation")] pub supports_disposable_email_validation: bool, /// Does plan support requiring canonical email addresses. #[serde(rename = "supportsCanonicalEmailValidation")] + #[serde(default = "default_supports_canonical_email_validation")] pub supports_canonical_email_validation: bool, /// Does plan support blocking free email addresses. #[serde(rename = "supportsFreeEmailValidation")] + #[serde(default = "default_supports_free_email_validation")] pub supports_free_email_validation: bool, /// Does plan support restricting sign-ups to corporate email addresses only. #[serde(rename = "supportsCorporateEmailValidation")] + #[serde(default = "default_supports_corporate_email_validation")] pub supports_corporate_email_validation: bool, /// Does plan support project-specific member roles. #[serde(rename = "supportsProjectSpecificRoles")] + #[serde(default = "default_supports_project_specific_roles")] pub supports_project_specific_roles: bool, /// Does plan support backup policies. #[serde(rename = "backupsEnabled")] @@ -209,6 +264,7 @@ pub struct BillingPlan { pub backups_enabled: Option, /// Whether usage addons are calculated per project. #[serde(rename = "usagePerProject")] + #[serde(default = "default_usage_per_project")] pub usage_per_project: bool, /// Supported addons for this plan #[serde(rename = "supportedAddons")] @@ -219,16 +275,20 @@ pub struct BillingPlan { pub backup_policies: Option, /// Maximum function and site deployment size in MB #[serde(rename = "deploymentSize")] + #[serde(default = "default_deployment_size")] pub deployment_size: i64, /// Maximum function and site deployment size in MB #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// Shortest function schedule interval allowed, in minutes. 0 allows every /// interval. #[serde(rename = "functionsIntervalMinimum")] + #[serde(default = "default_functions_interval_minimum")] pub functions_interval_minimum: i64, /// Does the plan support encrypted string attributes or not. #[serde(rename = "databasesAllowEncrypt")] + #[serde(default = "default_databases_allow_encrypt")] pub databases_allow_encrypt: bool, /// Plan specific limits #[serde(rename = "limits")] @@ -244,6 +304,7 @@ pub struct BillingPlan { /// Included monthly dedicated-database compute credit in USD. Resets each /// billing cycle with no roll-over. #[serde(rename = "databaseComputeCredit")] + #[serde(default = "default_database_compute_credit")] pub database_compute_credit: f64, /// Dedicated database limits available to this plan. #[serde(rename = "dedicatedDatabases")] @@ -251,6 +312,250 @@ pub struct BillingPlan { pub dedicated_databases: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_desc() -> String { + "".to_string() +} + +fn default_order() -> i64 { + 0 +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_trial() -> i64 { + 0 +} + +fn default_bandwidth() -> i64 { + 0 +} + +fn default_storage() -> i64 { + 0 +} + +fn default_image_transformations() -> i64 { + 0 +} + +fn default_screenshots_generated() -> i64 { + 0 +} + +fn default_webhooks() -> i64 { + 0 +} + +fn default_waf_rules() -> i64 { + 0 +} + +fn default_environments() -> i64 { + 0 +} + +fn default_projects() -> i64 { + 0 +} + +fn default_platforms() -> i64 { + 0 +} + +fn default_users() -> i64 { + 0 +} + +fn default_teams() -> i64 { + 0 +} + +fn default_databases() -> i64 { + 0 +} + +fn default_databases_reads() -> i64 { + 0 +} + +fn default_databases_writes() -> i64 { + 0 +} + +fn default_databases_batch_size() -> i64 { + 0 +} + +fn default_buckets() -> i64 { + 0 +} + +fn default_file_size() -> i64 { + 0 +} + +fn default_functions() -> i64 { + 0 +} + +fn default_sites() -> i64 { + 0 +} + +fn default_executions() -> i64 { + 0 +} + +fn default_executions_retention_count() -> i64 { + 1000 +} + +fn default_gb_hours() -> i64 { + 0 +} + +fn default_realtime() -> i64 { + 0 +} + +fn default_realtime_messages() -> i64 { + 0 +} + +fn default_messages() -> i64 { + 0 +} + +fn default_topics() -> i64 { + 0 +} + +fn default_auth_phone() -> i64 { + 0 +} + +fn default_domains() -> i64 { + 0 +} + +fn default_usage_logs() -> i64 { + 0 +} + +fn default_project_inactivity_days() -> i64 { + 0 +} + +fn default_alert_limit() -> i64 { + 80 +} + +fn default_budget_cap_enabled() -> bool { + false +} + +fn default_custom_smtp() -> bool { + false +} + +fn default_email_branding() -> bool { + false +} + +fn default_requires_payment_method() -> bool { + true +} + +fn default_requires_billing_address() -> bool { + false +} + +fn default_is_available() -> bool { + true +} + +fn default_self_service() -> bool { + true +} + +fn default_premium_support() -> bool { + true +} + +fn default_budgeting() -> bool { + true +} + +fn default_supports_mock_numbers() -> bool { + true +} + +fn default_supports_organization_roles() -> bool { + true +} + +fn default_supports_credits() -> bool { + false +} + +fn default_supports_dedicated_databases() -> bool { + false +} + +fn default_supports_disposable_email_validation() -> bool { + false +} + +fn default_supports_canonical_email_validation() -> bool { + false +} + +fn default_supports_free_email_validation() -> bool { + false +} + +fn default_supports_corporate_email_validation() -> bool { + false +} + +fn default_supports_project_specific_roles() -> bool { + false +} + +fn default_usage_per_project() -> bool { + true +} + +fn default_deployment_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_functions_interval_minimum() -> i64 { + 0 +} + +fn default_databases_allow_encrypt() -> bool { + false +} + +fn default_database_compute_credit() -> f64 { + 0.0 +} + impl BillingPlan { /// Get id pub fn id(&self) -> &String { @@ -323,15 +628,9 @@ impl BillingPlan { &self.waf_rules } - /// Set environments - pub fn set_environments(mut self, environments: i64) -> Self { - self.environments = Some(environments); - self - } - /// Get environments - pub fn environments(&self) -> Option<&i64> { - self.environments.as_ref() + pub fn environments(&self) -> &i64 { + &self.environments } /// Get projects @@ -490,9 +789,15 @@ impl BillingPlan { &self.alert_limit } + /// Set usage + pub fn set_usage(mut self, usage: crate::models::UsageBillingPlan) -> Self { + self.usage = Some(usage); + self + } + /// Get usage - pub fn usage(&self) -> &crate::models::UsageBillingPlan { - &self.usage + pub fn usage(&self) -> Option<&crate::models::UsageBillingPlan> { + self.usage.as_ref() } /// Get addons @@ -721,6 +1026,7 @@ mod tests { let _ = _model.screenshots_generated(); let _ = _model.webhooks(); let _ = _model.waf_rules(); + let _ = _model.environments(); let _ = _model.projects(); let _ = _model.platforms(); let _ = _model.users(); @@ -745,7 +1051,6 @@ mod tests { let _ = _model.usage_logs(); let _ = _model.project_inactivity_days(); let _ = _model.alert_limit(); - let _ = _model.usage(); let _ = _model.addons(); let _ = _model.budget_cap_enabled(); let _ = _model.custom_smtp(); diff --git a/src/models/billing_plan_addon_details.rs b/src/models/billing_plan_addon_details.rs index 00aa018..3557b0d 100644 --- a/src/models/billing_plan_addon_details.rs +++ b/src/models/billing_plan_addon_details.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanAddonDetails { /// Is the addon supported in the plan? #[serde(rename = "supported")] + #[serde(default = "default_supported")] pub supported: bool, /// Addon plan included value #[serde(rename = "planIncluded")] + #[serde(default = "default_plan_included")] pub plan_included: i64, /// Addon limit #[serde(rename = "limit")] + #[serde(default = "default_limit")] pub limit: i64, /// Addon type #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Price currency #[serde(rename = "currency")] @@ -24,15 +28,46 @@ pub struct BillingPlanAddonDetails { pub currency: Option, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_supported() -> bool { + false +} + +fn default_plan_included() -> i64 { + 0 +} + +fn default_limit() -> i64 { + 0 +} + +fn default_type() -> String { + "numeric".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl BillingPlanAddonDetails { /// Get supported pub fn supported(&self) -> &bool { diff --git a/src/models/billing_plan_supported_addons.rs b/src/models/billing_plan_supported_addons.rs index af95b2d..74f7ee1 100644 --- a/src/models/billing_plan_supported_addons.rs +++ b/src/models/billing_plan_supported_addons.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanSupportedAddons { /// Whether the plan supports BAA (Business Associate Agreement) addon #[serde(rename = "baa")] + #[serde(default = "default_baa")] pub baa: bool, /// Whether the plan supports Premium Geo DB addon (project-level) #[serde(rename = "premiumGeoDB")] + #[serde(default = "default_premium_geo_db")] pub premium_geo_db: bool, /// Whether the plan supports Premium Geo DB addon (organization-level) #[serde(rename = "premiumGeoDBOrg")] + #[serde(default = "default_premium_geo_db_org")] pub premium_geo_db_org: bool, } +fn default_baa() -> bool { + false +} + +fn default_premium_geo_db() -> bool { + false +} + +fn default_premium_geo_db_org() -> bool { + false +} + impl BillingPlanSupportedAddons { /// Get baa pub fn baa(&self) -> &bool { diff --git a/src/models/block.rs b/src/models/block.rs index 9bd4591..8af751d 100644 --- a/src/models/block.rs +++ b/src/models/block.rs @@ -8,40 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct Block { /// Block creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource type that is blocked #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource identifier that is blocked #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Block mode. full blocks reads and writes; readOnly blocks writes only. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, - /// Reason for the block. Can be null if no reason was provided. - #[serde(rename = "reason")] - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// Block expiration date in ISO 8601 format. Can be null if the block does not /// expire. #[serde(rename = "expiredAt")] #[serde(skip_serializing_if = "Option::is_none")] pub expired_at: Option, - /// Name of the project this block applies to. - #[serde(rename = "projectName")] - pub project_name: String, - /// Region of the project this block applies to. - #[serde(rename = "region")] - pub region: String, - /// Name of the organization that owns the project. - #[serde(rename = "organizationName")] - pub organization_name: String, - /// ID of the organization that owns the project. - #[serde(rename = "organizationId")] - pub organization_id: String, - /// Billing plan of the organization that owns the project. - #[serde(rename = "billingPlan")] - pub billing_plan: String, +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_mode() -> String { + "full".to_string() } impl Block { @@ -65,17 +66,6 @@ impl Block { &self.mode } - /// Set reason - pub fn set_reason(mut self, reason: String) -> Self { - self.reason = Some(reason); - self - } - - /// Get reason - pub fn reason(&self) -> Option<&String> { - self.reason.as_ref() - } - /// Set expired_at pub fn set_expired_at(mut self, expired_at: String) -> Self { self.expired_at = Some(expired_at); @@ -86,31 +76,6 @@ impl Block { pub fn expired_at(&self) -> Option<&String> { self.expired_at.as_ref() } - - /// Get project_name - pub fn project_name(&self) -> &String { - &self.project_name - } - - /// Get region - pub fn region(&self) -> &String { - &self.region - } - - /// Get organization_name - pub fn organization_name(&self) -> &String { - &self.organization_name - } - - /// Get organization_id - pub fn organization_id(&self) -> &String { - &self.organization_id - } - - /// Get billing_plan - pub fn billing_plan(&self) -> &String { - &self.billing_plan - } } #[cfg(test)] @@ -124,11 +89,6 @@ mod tests { let _ = _model.resource_type(); let _ = _model.resource_id(); let _ = _model.mode(); - let _ = _model.project_name(); - let _ = _model.region(); - let _ = _model.organization_name(); - let _ = _model.organization_id(); - let _ = _model.billing_plan(); } #[test] diff --git a/src/models/bucket.rs b/src/models/bucket.rs index 8140e6a..feffbb9 100644 --- a/src/models/bucket.rs +++ b/src/models/bucket.rs @@ -8,52 +8,122 @@ use serde::{Deserialize, Serialize}; pub struct Bucket { /// Bucket ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Bucket update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Bucket permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Whether file-level security is enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "fileSecurity")] + #[serde(default = "default_file_security")] pub file_security: bool, /// Bucket name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Bucket enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Maximum file size supported. #[serde(rename = "maximumFileSize")] + #[serde(default = "default_maximum_file_size")] pub maximum_file_size: i64, /// Allowed file extensions. #[serde(rename = "allowedFileExtensions")] + #[serde(default = "default_allowed_file_extensions")] pub allowed_file_extensions: Vec, /// Compression algorithm chosen for compression. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, /// Bucket is encrypted. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Virus scanning is enabled. #[serde(rename = "antivirus")] + #[serde(default = "default_antivirus")] pub antivirus: bool, /// Image transformations are enabled. #[serde(rename = "transformations")] + #[serde(default = "default_transformations")] pub transformations: bool, /// Total size of this bucket in bytes. #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_file_security() -> bool { + false +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_maximum_file_size() -> i64 { + 0 +} + +fn default_allowed_file_extensions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_compression() -> String { + "".to_string() +} + +fn default_encryption() -> bool { + true +} + +fn default_antivirus() -> bool { + true +} + +fn default_transformations() -> bool { + true +} + +fn default_total_size() -> i64 { + 0 +} + impl Bucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/bucket_list.rs b/src/models/bucket_list.rs index 0f76efc..a29bb00 100644 --- a/src/models/bucket_list.rs +++ b/src/models/bucket_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BucketList { /// Total number of buckets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of buckets. #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_buckets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BucketList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/collection.rs b/src/models/collection.rs index 715c303..fd9bc8a 100644 --- a/src/models/collection.rs +++ b/src/models/collection.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Collection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Collection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/collection_list.rs b/src/models/collection_list.rs index 97983c6..c9f7bfe 100644 --- a/src/models/collection_list.rs +++ b/src/models/collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_bigint.rs b/src/models/column_bigint.rs index 1228086..9dd23d7 100644 --- a/src/models/column_bigint.rs +++ b/src/models/column_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBigint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBigint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBigint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_boolean.rs b/src/models/column_boolean.rs index 65aa9af..d2f4fe9 100644 --- a/src/models/column_boolean.rs +++ b/src/models/column_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBoolean { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBoolean { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_datetime.rs b/src/models/column_datetime.rs index a172665..13c23ca 100644 --- a/src/models/column_datetime.rs +++ b/src/models/column_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnDatetime { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnDatetime { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct ColumnDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_email.rs b/src/models/column_email.rs index f1c1037..5fc9bb6 100644 --- a/src/models/column_email.rs +++ b/src/models/column_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEmail { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEmail { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnEmail { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl ColumnEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_enum.rs b/src/models/column_enum.rs index d9b6b4f..bf66e79 100644 --- a/src/models/column_enum.rs +++ b/src/models/column_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEnum { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEnum { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct ColumnEnum { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -46,6 +54,38 @@ pub struct ColumnEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl ColumnEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_float.rs b/src/models/column_float.rs index 865bd38..55326bc 100644 --- a/src/models/column_float.rs +++ b/src/models/column_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnFloat { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnFloat { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnFloat { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_index.rs b/src/models/column_index.rs index 7e2a97b..ec406a7 100644 --- a/src/models/column_index.rs +++ b/src/models/column_index.rs @@ -8,32 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndex { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Index columns length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +50,42 @@ pub struct ColumnIndex { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/column_index_list.rs b/src/models/column_index_list.rs index 2ea7645..748a2c5 100644 --- a/src/models/column_index_list.rs +++ b/src/models/column_index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_integer.rs b/src/models/column_integer.rs index 8a6cd9e..39fb5f6 100644 --- a/src/models/column_integer.rs +++ b/src/models/column_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnInteger { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnInteger { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnInteger { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_ip.rs b/src/models/column_ip.rs index a94cf00..9aa5287 100644 --- a/src/models/column_ip.rs +++ b/src/models/column_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIp { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnIp { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnIp { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl ColumnIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_line.rs b/src/models/column_line.rs index 01d2239..6befae7 100644 --- a/src/models/column_line.rs +++ b/src/models/column_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLine { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLine { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLine { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_list.rs b/src/models/column_list.rs index aaa362b..55fc758 100644 --- a/src/models/column_list.rs +++ b/src/models/column_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnList { /// Total number of columns in the given table. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_longtext.rs b/src/models/column_longtext.rs index 6d418d9..222e746 100644 --- a/src/models/column_longtext.rs +++ b/src/models/column_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLongtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLongtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_mediumtext.rs b/src/models/column_mediumtext.rs index 90b3d33..f1c032b 100644 --- a/src/models/column_mediumtext.rs +++ b/src/models/column_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnMediumtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnMediumtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_point.rs b/src/models/column_point.rs index 6d402ea..4b08010 100644 --- a/src/models/column_point.rs +++ b/src/models/column_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPoint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPoint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPoint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_polygon.rs b/src/models/column_polygon.rs index d0afe7e..5ff50f0 100644 --- a/src/models/column_polygon.rs +++ b/src/models/column_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPolygon { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPolygon { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPolygon { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_relationship.rs b/src/models/column_relationship.rs index 441476a..92304e7 100644 --- a/src/models/column_relationship.rs +++ b/src/models/column_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnRelationship { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct ColumnRelationship { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related table. #[serde(rename = "relatedTable")] pub related_table: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl ColumnRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_string.rs b/src/models/column_string.rs index c7128c3..8d8e515 100644 --- a/src/models/column_string.rs +++ b/src/models/column_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnString { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnString { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnString { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_text.rs b/src/models/column_text.rs index 0ad76c5..e1b305c 100644 --- a/src/models/column_text.rs +++ b/src/models/column_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnText { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnText { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnText { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_url.rs b/src/models/column_url.rs index b509d2f..4fce4a3 100644 --- a/src/models/column_url.rs +++ b/src/models/column_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnUrl { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnUrl { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnUrl { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl ColumnUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_varchar.rs b/src/models/column_varchar.rs index e163c87..53e8c58 100644 --- a/src/models/column_varchar.rs +++ b/src/models/column_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnVarchar { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnVarchar { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/continent.rs b/src/models/continent.rs index c13199c..34286cd 100644 --- a/src/models/continent.rs +++ b/src/models/continent.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Continent { /// Continent name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Continent two letter code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Continent { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/continent_list.rs b/src/models/continent_list.rs index 2490dbd..677e579 100644 --- a/src/models/continent_list.rs +++ b/src/models/continent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ContinentList { /// Total number of continents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of continents. #[serde(rename = "continents")] + #[serde(default = "default_continents")] pub continents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_continents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ContinentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/country.rs b/src/models/country.rs index bf48f60..2c9db22 100644 --- a/src/models/country.rs +++ b/src/models/country.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Country { /// Country name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Country { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/country_list.rs b/src/models/country_list.rs index bf4eeb1..b004cb8 100644 --- a/src/models/country_list.rs +++ b/src/models/country_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CountryList { /// Total number of countries that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of countries. #[serde(rename = "countries")] + #[serde(default = "default_countries")] pub countries: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_countries() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CountryList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/currency.rs b/src/models/currency.rs index 9d45fe6..c5d5091 100644 --- a/src/models/currency.rs +++ b/src/models/currency.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct Currency { /// Currency symbol. #[serde(rename = "symbol")] + #[serde(default = "default_symbol")] pub symbol: String, /// Currency name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Currency native symbol. #[serde(rename = "symbolNative")] + #[serde(default = "default_symbol_native")] pub symbol_native: String, /// Number of decimal digits. #[serde(rename = "decimalDigits")] + #[serde(default = "default_decimal_digits")] pub decimal_digits: i64, /// Currency digit rounding. #[serde(rename = "rounding")] + #[serde(default = "default_rounding")] pub rounding: f64, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Currency plural name #[serde(rename = "namePlural")] + #[serde(default = "default_name_plural")] pub name_plural: String, } +fn default_symbol() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_symbol_native() -> String { + "".to_string() +} + +fn default_decimal_digits() -> i64 { + 0 +} + +fn default_rounding() -> f64 { + 0.0 +} + +fn default_code() -> String { + "".to_string() +} + +fn default_name_plural() -> String { + "".to_string() +} + impl Currency { /// Get symbol pub fn symbol(&self) -> &String { diff --git a/src/models/currency_list.rs b/src/models/currency_list.rs index 86fa828..001a779 100644 --- a/src/models/currency_list.rs +++ b/src/models/currency_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CurrencyList { /// Total number of currencies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of currencies. #[serde(rename = "currencies")] + #[serde(default = "default_currencies")] pub currencies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_currencies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CurrencyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database.rs b/src/models/database.rs index 5c0a45d..b582d01 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -8,23 +8,29 @@ use serde::{Deserialize, Serialize}; pub struct Database { /// Database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Database creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the /// database is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Database type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: crate::enums::DatabaseType, /// Dedicated database lifecycle status. Null when the database has no valid /// dedicated backing. @@ -53,8 +59,9 @@ pub struct Database { #[serde(rename = "error")] #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, - /// Container status of the dedicated backing: active or inactive. Null when - /// the database has no dedicated backing or the runtime has not reported one. + /// Container status of the dedicated backing: active, inactive, or failed (a + /// wake was declined because the backing namespace is gone). Null when the + /// database has no dedicated backing or the runtime has not reported one. #[serde(rename = "containerStatus")] #[serde(skip_serializing_if = "Option::is_none")] pub container_status: Option, @@ -74,6 +81,30 @@ pub struct Database { pub archives: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> crate::enums::DatabaseType { + serde_json::from_value(serde_json::json!("legacy")).unwrap() +} + impl Database { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_list.rs b/src/models/database_list.rs index 78fe039..919f60b 100644 --- a/src/models/database_list.rs +++ b/src/models/database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_migration.rs b/src/models/database_migration.rs index 0a05aa6..e2ca204 100644 --- a/src/models/database_migration.rs +++ b/src/models/database_migration.rs @@ -8,63 +8,148 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigration { /// Database migration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Migration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Migration update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns the migrating database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Logical database ID being migrated. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Dedicated compute specification provisioned for the migration target. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Migration phase. Possible values: pending, provisioned, capturing, /// backfilling, catching_up, verifying, ready_to_cutover, cutover, soaking, /// done, failed, rolled_back. #[serde(rename = "phase")] + #[serde(default = "default_phase")] pub phase: String, /// Number of times a migration step has failed and been recorded. #[serde(rename = "attempt")] + #[serde(default = "default_attempt")] pub attempt: i64, /// Reason the most recent migration step failed, empty while none has. #[serde(rename = "lastError")] + #[serde(default = "default_last_error")] pub last_error: String, /// Number of documents still pending replication to the target. #[serde(rename = "lagDocuments")] + #[serde(default = "default_lag_documents")] pub lag_documents: i64, /// Highest source changelog sequence applied to the target so far. #[serde(rename = "changelogWatermark")] + #[serde(default = "default_changelog_watermark")] pub changelog_watermark: i64, /// Time the migrated data was verified against the source in ISO 8601 format. #[serde(rename = "verifiedAt")] + #[serde(default = "default_verified_at")] pub verified_at: String, /// Time routing was flipped to the target in ISO 8601 format. #[serde(rename = "cutoverAt")] + #[serde(default = "default_cutover_at")] pub cutover_at: String, /// Time the post-cutover soak window ends in ISO 8601 format. #[serde(rename = "soakUntil")] + #[serde(default = "default_soak_until")] pub soak_until: String, /// Whether the migration cuts over automatically once ready. Set when the /// migration is created and never changed afterwards, so it always reports /// what was asked for. #[serde(rename = "autoCutover")] + #[serde(default = "default_auto_cutover")] pub auto_cutover: bool, /// Whether a cutover has been requested and not yet attempted. Set by the /// cutover endpoint and cleared when the attempt is made, so a cutover that /// fails a check parks the migration again rather than retrying on its own. #[serde(rename = "cutoverRequested")] + #[serde(default = "default_cutover_requested")] pub cutover_requested: bool, /// Whether the migration is paused. #[serde(rename = "paused")] + #[serde(default = "default_paused")] pub paused: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_phase() -> String { + "pending".to_string() +} + +fn default_attempt() -> i64 { + 0 +} + +fn default_last_error() -> String { + "".to_string() +} + +fn default_lag_documents() -> i64 { + 0 +} + +fn default_changelog_watermark() -> i64 { + 0 +} + +fn default_verified_at() -> String { + "".to_string() +} + +fn default_cutover_at() -> String { + "".to_string() +} + +fn default_soak_until() -> String { + "".to_string() +} + +fn default_auto_cutover() -> bool { + true +} + +fn default_cutover_requested() -> bool { + false +} + +fn default_paused() -> bool { + false +} + impl DatabaseMigration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_migration_list.rs b/src/models/database_migration_list.rs index ad8e45f..1029847 100644 --- a/src/models/database_migration_list.rs +++ b/src/models/database_migration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigrationList { /// Total number of migrations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of migrations. #[serde(rename = "migrations")] + #[serde(default = "default_migrations")] pub migrations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_migrations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseMigrationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_status.rs b/src/models/database_status.rs index d0b0403..0796051 100644 --- a/src/models/database_status.rs +++ b/src/models/database_status.rs @@ -9,25 +9,32 @@ pub struct DatabaseStatus { /// Overall health status: healthy, degraded, unhealthy, or unknown when /// nothing could be measured. #[serde(rename = "health")] + #[serde(default = "default_health")] pub health: String, /// Whether the database is ready to accept connections. #[serde(rename = "ready")] + #[serde(default = "default_ready")] pub ready: bool, /// Database engine: postgresql, mysql, or mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Database uptime in seconds. #[serde(rename = "uptime")] + #[serde(default = "default_uptime")] pub uptime: i64, - /// Connection statistics. + /// Connection statistics. Null when the database has not been probed. #[serde(rename = "connections")] - pub connections: crate::models::DatabaseStatusConnections, + #[serde(skip_serializing_if = "Option::is_none")] + pub connections: Option, /// Requested replication sync mode. Possible values: async, sync, quorum. /// Compare with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. @@ -36,13 +43,16 @@ pub struct DatabaseStatus { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -62,12 +72,58 @@ pub struct DatabaseStatus { /// appears, including one the backend has not brought up, which is reported as /// not healthy. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: Vec, /// Storage volume information. #[serde(rename = "volumes")] + #[serde(default = "default_volumes")] pub volumes: Vec, } +fn default_health() -> String { + "unknown".to_string() +} + +fn default_ready() -> bool { + false +} + +fn default_engine() -> String { + "postgresql".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_uptime() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_replicas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_volumes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseStatus { /// Get health pub fn health(&self) -> &String { @@ -94,9 +150,18 @@ impl DatabaseStatus { &self.uptime } + /// Set connections + pub fn set_connections( + mut self, + connections: crate::models::DatabaseStatusConnections, + ) -> Self { + self.connections = Some(connections); + self + } + /// Get connections - pub fn connections(&self) -> &crate::models::DatabaseStatusConnections { - &self.connections + pub fn connections(&self) -> Option<&crate::models::DatabaseStatusConnections> { + self.connections.as_ref() } /// Get sync_mode @@ -164,7 +229,6 @@ mod tests { let _ = _model.engine(); let _ = _model.version(); let _ = _model.uptime(); - let _ = _model.connections(); let _ = _model.sync_mode(); let _ = _model.sync_degraded(); let _ = _model.sync_acknowledgements(); diff --git a/src/models/database_status_connections.rs b/src/models/database_status_connections.rs index 0e7652d..8d7110a 100644 --- a/src/models/database_status_connections.rs +++ b/src/models/database_status_connections.rs @@ -8,14 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusConnections { /// Current number of active connections. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: i64, /// The engine's own max_connections. On a pooled database this is the backend /// limit the pooler multiplexes onto, not the ceiling a client pool may reach /// — that is networkMaxConnections on the database resource. #[serde(rename = "max")] + #[serde(default = "default_max")] pub max: i64, } +fn default_current() -> i64 { + 0 +} + +fn default_max() -> i64 { + 100 +} + impl DatabaseStatusConnections { /// Get current pub fn current(&self) -> &i64 { diff --git a/src/models/database_status_replica.rs b/src/models/database_status_replica.rs index f182cdb..ad15e30 100644 --- a/src/models/database_status_replica.rs +++ b/src/models/database_status_replica.rs @@ -9,15 +9,18 @@ pub struct DatabaseStatusReplica { /// Member index within the database. Read `role` for which member accepts /// writes: a failover moves the primary without renumbering the indexes. #[serde(rename = "index")] + #[serde(default = "default_index")] pub index: i64, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology, so no member can be named /// the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Whether the replica is healthy. #[serde(rename = "healthy")] + #[serde(default = "default_healthy")] pub healthy: bool, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -35,6 +38,18 @@ pub struct DatabaseStatusReplica { pub lag_seconds: Option, } +fn default_index() -> i64 { + 0 +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_healthy() -> bool { + false +} + impl DatabaseStatusReplica { /// Get index pub fn index(&self) -> &i64 { diff --git a/src/models/database_status_volume.rs b/src/models/database_status_volume.rs index 35ea096..0d21f7a 100644 --- a/src/models/database_status_volume.rs +++ b/src/models/database_status_volume.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusVolume { /// Mount path of the volume. #[serde(rename = "path")] + #[serde(default = "default_path")] pub path: String, /// Percentage of storage used. #[serde(rename = "usedPercent")] + #[serde(default = "default_used_percent")] pub used_percent: String, /// Available storage space. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: String, /// Whether the volume is mounted. #[serde(rename = "mounted")] + #[serde(default = "default_mounted")] pub mounted: bool, } +fn default_path() -> String { + "".to_string() +} + +fn default_used_percent() -> String { + "0%".to_string() +} + +fn default_available() -> String { + "0GB".to_string() +} + +fn default_mounted() -> bool { + false +} + impl DatabaseStatusVolume { /// Get path pub fn path(&self) -> &String { diff --git a/src/models/dedicated_database.rs b/src/models/dedicated_database.rs index 33e9d5c..07cf2c4 100644 --- a/src/models/dedicated_database.rs +++ b/src/models/dedicated_database.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabase { /// Dedicated database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns this database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Database display name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Product API that owns this database: tablesdb, documentsdb, vectorsdb, /// mysql, postgresql, or mongodb. #[serde(rename = "api")] - pub api: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub api: Option, /// Database engine: postgresql, mysql, or mongodb. Null until the backing /// reports one. #[serde(rename = "engine")] - pub engine: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub engine: Option, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Specification identifier. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Database backend provider. Possible values: edge. #[serde(rename = "backend")] + #[serde(default = "default_backend")] pub backend: String, /// Database hostname for connections. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Database port for connections. Derived from the engine when the backing has /// not reported one yet. #[serde(rename = "connectionPort")] - pub connection_port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub connection_port: Option, /// Database username for connections. #[serde(rename = "connectionUser")] + #[serde(default = "default_connection_user")] pub connection_user: String, /// Database password for connections. #[serde(rename = "connectionPassword")] + #[serde(default = "default_connection_password")] pub connection_password: String, /// Committed generation of the primary connection credentials. Null until the /// rotation contract has been initialized. #[serde(rename = "credentialGeneration")] - pub credential_generation: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub credential_generation: Option, /// Full database connection string (URI format). #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, /// Whether SSL/TLS is required for client connections. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database status. Possible values: provisioning, ready, inactive, paused, /// failed, deleted, restoring, scaling. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// Container status for lifecycle-managed database runtimes: active or - /// inactive. + /// Container status for lifecycle-managed database runtimes: active, inactive, + /// or failed (a wake was declined because the backing namespace is gone). #[serde(rename = "containerStatus")] + #[serde(default = "default_container_status")] pub container_status: String, /// Last activity timestamp in ISO 8601 format. #[serde(rename = "lastAccessedAt")] @@ -82,29 +101,34 @@ pub struct DedicatedDatabase { /// Idle-lifecycle state of the database. Possible values: active, warm, cold, /// hibernated. #[serde(rename = "lifecycleState")] + #[serde(default = "default_lifecycle_state")] pub lifecycle_state: String, /// Minutes of inactivity before container scales to zero. #[serde(rename = "idleTimeoutMinutes")] + #[serde(default = "default_idle_timeout_minutes")] pub idle_timeout_minutes: i64, /// CPU allocated in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Memory allocated in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Storage allocated in GB. #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Storage resize status. Possible values: idle (no resize in flight), /// resizing (the volume is growing towards storageTargetGb). #[serde(rename = "storageStatus")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_status: Option, + #[serde(default = "default_storage_status")] + pub storage_status: String, /// Size in GB the volume is growing towards while storageStatus is resizing. 0 /// when no resize is in flight. #[serde(rename = "storageTargetGb")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_target_gb: Option, + #[serde(default = "default_storage_target_gb")] + pub storage_target_gb: i64, /// Time the in-flight storage resize started, in ISO 8601 format. #[serde(rename = "storageResizeStartedAt")] #[serde(skip_serializing_if = "Option::is_none")] @@ -112,86 +136,290 @@ pub struct DedicatedDatabase { /// Storage class. Currently always 'ssd'; DigitalOcean exposes a single /// block-storage class. #[serde(rename = "storageClass")] + #[serde(default = "default_storage_class")] pub storage_class: String, /// Maximum storage allowed in GB. 0 means use system default. #[serde(rename = "storageMaxGb")] + #[serde(default = "default_storage_max_gb")] pub storage_max_gb: i64, /// Kubernetes node pool where the database is scheduled. #[serde(rename = "nodePool")] + #[serde(default = "default_node_pool")] pub node_pool: String, /// Number of high availability replicas. High availability is enabled when /// greater than 0. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Replication sync mode: async, sync, or quorum. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Maximum concurrent client connections. This is the limit a client pool may /// reach; the engine's own max_connections reported by the status endpoint is /// a smaller backend limit the pooler multiplexes onto and does not constrain /// a client pool. #[serde(rename = "networkMaxConnections")] + #[serde(default = "default_network_max_connections")] pub network_max_connections: i64, /// Connection idle timeout in seconds. #[serde(rename = "networkIdleTimeoutSeconds")] + #[serde(default = "default_network_idle_timeout_seconds")] pub network_idle_timeout_seconds: i64, /// IP addresses/CIDR ranges allowed to connect. #[serde(rename = "networkIPAllowlist")] + #[serde(default = "default_network_ip_allowlist")] pub network_ip_allowlist: Vec, /// Whether automatic backups are enabled. #[serde(rename = "backupEnabled")] + #[serde(default = "default_backup_enabled")] pub backup_enabled: bool, /// Whether point-in-time recovery is enabled. #[serde(rename = "pitr")] + #[serde(default = "default_pitr")] pub pitr: bool, /// Number of days to retain PITR data. #[serde(rename = "pitrRetentionDays")] + #[serde(default = "default_pitr_retention_days")] pub pitr_retention_days: i64, /// Whether automatic storage expansion is enabled. #[serde(rename = "storageAutoscaling")] + #[serde(default = "default_storage_autoscaling")] pub storage_autoscaling: bool, /// Storage usage percentage that triggers automatic expansion. #[serde(rename = "storageAutoscalingThresholdPercent")] + #[serde(default = "default_storage_autoscaling_threshold_percent")] pub storage_autoscaling_threshold_percent: i64, - /// Maximum storage size in GB for autoscaling. 0 means no limit. + /// Maximum storage size in GB for autoscaling. Defaults to 3 times the + /// specification's storage. 0 means no limit. #[serde(rename = "storageAutoscalingMaxGb")] + #[serde(default = "default_storage_autoscaling_max_gb")] pub storage_autoscaling_max_gb: i64, /// Day of the week for the maintenance window. Possible values: sun, mon, tue, /// wed, thu, fri, sat. #[serde(rename = "maintenanceWindowDay")] + #[serde(default = "default_maintenance_window_day")] pub maintenance_window_day: String, /// Hour in UTC (0-23) when the maintenance window starts. #[serde(rename = "maintenanceWindowHourUtc")] + #[serde(default = "default_maintenance_window_hour_utc")] pub maintenance_window_hour_utc: i64, /// Whether metrics collection is enabled. #[serde(rename = "metricsEnabled")] + #[serde(default = "default_metrics_enabled")] pub metrics_enabled: bool, /// Whether the SQL API sidecar is enabled for this database. #[serde(rename = "sqlApiEnabled")] + #[serde(default = "default_sql_api_enabled")] pub sql_api_enabled: bool, /// Statement types accepted by the SQL API. Defaults to read/write DML only; /// DDL/DCL types (CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE) are opt-in per /// database. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, /// DROP, TRUNCATE, GRANT, REVOKE. #[serde(rename = "sqlApiAllowedStatements")] + #[serde(default = "default_sql_api_allowed_statements")] pub sql_api_allowed_statements: Vec, /// Maximum rows returned per SQL API execution. Results larger than this are /// truncated. #[serde(rename = "sqlApiMaxRows")] + #[serde(default = "default_sql_api_max_rows")] pub sql_api_max_rows: i64, /// Maximum serialised SQL API result payload in bytes. Results larger than /// this are truncated. #[serde(rename = "sqlApiMaxBytes")] + #[serde(default = "default_sql_api_max_bytes")] pub sql_api_max_bytes: i64, /// Maximum server-side SQL API execution time in seconds before the query is /// cancelled. #[serde(rename = "sqlApiTimeoutSeconds")] + #[serde(default = "default_sql_api_timeout_seconds")] pub sql_api_timeout_seconds: i64, /// Error message if status is failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_backend() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_connection_user() -> String { + "".to_string() +} + +fn default_connection_password() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_status() -> String { + "provisioning".to_string() +} + +fn default_container_status() -> String { + "".to_string() +} + +fn default_lifecycle_state() -> String { + "".to_string() +} + +fn default_idle_timeout_minutes() -> i64 { + 15 +} + +fn default_cpu() -> i64 { + 500 +} + +fn default_memory() -> i64 { + 512 +} + +fn default_storage() -> i64 { + 10 +} + +fn default_storage_status() -> String { + "idle".to_string() +} + +fn default_storage_target_gb() -> i64 { + 0 +} + +fn default_storage_class() -> String { + "ssd".to_string() +} + +fn default_storage_max_gb() -> i64 { + 0 +} + +fn default_node_pool() -> String { + "".to_string() +} + +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "".to_string() +} + +fn default_network_max_connections() -> i64 { + 100 +} + +fn default_network_idle_timeout_seconds() -> i64 { + 900 +} + +fn default_network_ip_allowlist() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_backup_enabled() -> bool { + true +} + +fn default_pitr() -> bool { + true +} + +fn default_pitr_retention_days() -> i64 { + 7 +} + +fn default_storage_autoscaling() -> bool { + true +} + +fn default_storage_autoscaling_threshold_percent() -> i64 { + 85 +} + +fn default_storage_autoscaling_max_gb() -> i64 { + 0 +} + +fn default_maintenance_window_day() -> String { + "sun".to_string() +} + +fn default_maintenance_window_hour_utc() -> i64 { + 3 +} + +fn default_metrics_enabled() -> bool { + false +} + +fn default_sql_api_enabled() -> bool { + true +} + +fn default_sql_api_allowed_statements() -> Vec { + serde_json::from_value(serde_json::json!(["SELECT", "INSERT", "UPDATE", "DELETE"])).unwrap() +} + +fn default_sql_api_max_rows() -> i64 { + 10000 +} + +fn default_sql_api_max_bytes() -> i64 { + 10485760 +} + +fn default_sql_api_timeout_seconds() -> i64 { + 30 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabase { /// Get id pub fn id(&self) -> &String { @@ -218,14 +446,26 @@ impl DedicatedDatabase { &self.name } + /// Set api + pub fn set_api(mut self, api: String) -> Self { + self.api = Some(api); + self + } + /// Get api - pub fn api(&self) -> &String { - &self.api + pub fn api(&self) -> Option<&String> { + self.api.as_ref() + } + + /// Set engine + pub fn set_engine(mut self, engine: String) -> Self { + self.engine = Some(engine); + self } /// Get engine - pub fn engine(&self) -> &String { - &self.engine + pub fn engine(&self) -> Option<&String> { + self.engine.as_ref() } /// Get version @@ -248,9 +488,15 @@ impl DedicatedDatabase { &self.hostname } + /// Set connection_port + pub fn set_connection_port(mut self, connection_port: i64) -> Self { + self.connection_port = Some(connection_port); + self + } + /// Get connection_port - pub fn connection_port(&self) -> &i64 { - &self.connection_port + pub fn connection_port(&self) -> Option<&i64> { + self.connection_port.as_ref() } /// Get connection_user @@ -263,9 +509,15 @@ impl DedicatedDatabase { &self.connection_password } + /// Set credential_generation + pub fn set_credential_generation(mut self, credential_generation: i64) -> Self { + self.credential_generation = Some(credential_generation); + self + } + /// Get credential_generation - pub fn credential_generation(&self) -> &i64 { - &self.credential_generation + pub fn credential_generation(&self) -> Option<&i64> { + self.credential_generation.as_ref() } /// Get connection_string @@ -335,26 +587,14 @@ impl DedicatedDatabase { &self.storage } - /// Set storage_status - pub fn set_storage_status(mut self, storage_status: String) -> Self { - self.storage_status = Some(storage_status); - self - } - /// Get storage_status - pub fn storage_status(&self) -> Option<&String> { - self.storage_status.as_ref() - } - - /// Set storage_target_gb - pub fn set_storage_target_gb(mut self, storage_target_gb: i64) -> Self { - self.storage_target_gb = Some(storage_target_gb); - self + pub fn storage_status(&self) -> &String { + &self.storage_status } /// Get storage_target_gb - pub fn storage_target_gb(&self) -> Option<&i64> { - self.storage_target_gb.as_ref() + pub fn storage_target_gb(&self) -> &i64 { + &self.storage_target_gb } /// Set storage_resize_started_at @@ -496,16 +736,12 @@ mod tests { let _ = _model.updated_at(); let _ = _model.project_id(); let _ = _model.name(); - let _ = _model.api(); - let _ = _model.engine(); let _ = _model.version(); let _ = _model.specification(); let _ = _model.backend(); let _ = _model.hostname(); - let _ = _model.connection_port(); let _ = _model.connection_user(); let _ = _model.connection_password(); - let _ = _model.credential_generation(); let _ = _model.connection_string(); let _ = _model.ssl(); let _ = _model.status(); @@ -515,6 +751,8 @@ mod tests { let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.storage(); + let _ = _model.storage_status(); + let _ = _model.storage_target_gb(); let _ = _model.storage_class(); let _ = _model.storage_max_gb(); let _ = _model.node_pool(); diff --git a/src/models/dedicated_database_backup.rs b/src/models/dedicated_database_backup.rs index 703d3d6..cef73b2 100644 --- a/src/models/dedicated_database_backup.rs +++ b/src/models/dedicated_database_backup.rs @@ -8,44 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackup { /// Backup ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID this backup belongs to. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup policy ID when the backup was created by a schedule. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// Backup trigger. Possible values: manual, schedule. #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup), wal (write-ahead log continuous /// archival). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Backup type that was requested. Differs from `type` when the backend could /// not run the requested type and took a different one instead, in which case /// `fallbackReason` explains why. Empty for backups taken before the requested /// type was recorded. #[serde(rename = "requestedType")] + #[serde(default = "default_requested_type")] pub requested_type: String, /// Why the backend ran a different backup type than the one requested. Empty /// when the backup ran as requested. #[serde(rename = "fallbackReason")] + #[serde(default = "default_fallback_reason")] pub fallback_reason: String, /// Backup status. Possible values: pending (queued for processing), running /// (currently in progress), completed (successfully finished), failed /// (encountered an error), verified (integrity check passed). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Backup size in bytes. #[serde(rename = "sizeBytes")] + #[serde(default = "default_size_bytes")] pub size_bytes: i64, /// Backup start time in ISO 8601 format. #[serde(rename = "startedAt")] @@ -73,9 +84,58 @@ pub struct DedicatedDatabaseBackup { pub log_position: Option, /// Error message if backup failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "manual".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_requested_type() -> String { + "".to_string() +} + +fn default_fallback_reason() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_size_bytes() -> i64 { + 0 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseBackup { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_backup_list.rs b/src/models/dedicated_database_backup_list.rs index 4833b14..7f173ad 100644 --- a/src/models/dedicated_database_backup_list.rs +++ b/src/models/dedicated_database_backup_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackupList { /// Total number of backups. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of backups. #[serde(rename = "backups")] + #[serde(default = "default_backups")] pub backups: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_backups() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBackupList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_backup_storage.rs b/src/models/dedicated_database_backup_storage.rs index 395e376..6756910 100644 --- a/src/models/dedicated_database_backup_storage.rs +++ b/src/models/dedicated_database_backup_storage.rs @@ -9,21 +9,46 @@ pub struct DedicatedDatabaseBackupStorage { /// Storage provider. Possible values: s3 (Amazon S3 or S3-compatible), gcs /// (Google Cloud Storage), azure (Azure Blob Storage). #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Storage bucket or container name. #[serde(rename = "bucket")] + #[serde(default = "default_bucket")] pub bucket: String, /// Storage region. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// Object key prefix for backups. #[serde(rename = "prefix")] + #[serde(default = "default_prefix")] pub prefix: String, /// Custom endpoint for S3-compatible storage. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_provider() -> String { + "".to_string() +} + +fn default_bucket() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_prefix() -> String { + "backups/".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl DedicatedDatabaseBackupStorage { /// Get provider pub fn provider(&self) -> &String { diff --git a/src/models/dedicated_database_branch.rs b/src/models/dedicated_database_branch.rs index db3bc19..6d283bf 100644 --- a/src/models/dedicated_database_branch.rs +++ b/src/models/dedicated_database_branch.rs @@ -8,43 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranch { /// Branch identifier. #[serde(rename = "branchId")] + #[serde(default = "default_branch_id")] pub branch_id: String, /// Branch name. #[serde(rename = "branchName")] + #[serde(default = "default_branch_name")] pub branch_name: String, /// Kubernetes namespace where the branch is deployed. #[serde(rename = "namespace")] + #[serde(default = "default_namespace")] pub namespace: String, /// Unix timestamp when the branch expires. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: i64, /// Branch hostname for direct connections. #[serde(rename = "host")] + #[serde(default = "default_host")] pub host: String, /// Branch port. Null until the backing reports one. #[serde(rename = "port")] - pub port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub port: Option, /// Advertised catalog the client connects to. MySQL/MariaDB use default; /// Postgres uses the routing label. #[serde(rename = "database")] + #[serde(default = "default_database")] pub database: String, /// Database username. Shared with the parent database. #[serde(rename = "username")] + #[serde(default = "default_username")] pub username: String, /// Database password. Shared with the parent database. #[serde(rename = "password")] + #[serde(default = "default_password")] pub password: String, /// Whether SSL is required. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database engine. Possible values: postgresql, mysql, mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Full connection string for the branch. #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, } +fn default_branch_id() -> String { + "".to_string() +} + +fn default_branch_name() -> String { + "".to_string() +} + +fn default_namespace() -> String { + "".to_string() +} + +fn default_expires_at() -> i64 { + 0 +} + +fn default_host() -> String { + "".to_string() +} + +fn default_database() -> String { + "".to_string() +} + +fn default_username() -> String { + "".to_string() +} + +fn default_password() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_engine() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + impl DedicatedDatabaseBranch { /// Get branch_id pub fn branch_id(&self) -> &String { @@ -71,9 +127,15 @@ impl DedicatedDatabaseBranch { &self.host } + /// Set port + pub fn set_port(mut self, port: i64) -> Self { + self.port = Some(port); + self + } + /// Get port - pub fn port(&self) -> &i64 { - &self.port + pub fn port(&self) -> Option<&i64> { + self.port.as_ref() } /// Get database @@ -119,7 +181,6 @@ mod tests { let _ = _model.namespace(); let _ = _model.expires_at(); let _ = _model.host(); - let _ = _model.port(); let _ = _model.database(); let _ = _model.username(); let _ = _model.password(); diff --git a/src/models/dedicated_database_branch_list.rs b/src/models/dedicated_database_branch_list.rs index 50da757..adb1575 100644 --- a/src/models/dedicated_database_branch_list.rs +++ b/src/models/dedicated_database_branch_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranchList { /// Total number of branches. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of branches. #[serde(rename = "branches")] + #[serde(default = "default_branches")] pub branches: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBranchList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_execution.rs b/src/models/dedicated_database_execution.rs index cbd430a..5998d80 100644 --- a/src/models/dedicated_database_execution.rs +++ b/src/models/dedicated_database_execution.rs @@ -9,26 +9,56 @@ pub struct DedicatedDatabaseExecution { /// Result rows as a list of column-name => value maps. Empty for non-returning /// statements. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, /// Number of rows returned (for SELECT) or affected (for /// INSERT/UPDATE/DELETE). #[serde(rename = "rowCount")] + #[serde(default = "default_row_count")] pub row_count: i64, /// Column metadata in result-set order. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Server-side execution time in milliseconds. #[serde(rename = "durationMs")] + #[serde(default = "default_duration_ms")] pub duration_ms: i64, /// True when the configured row or byte cap was hit and the result was /// truncated. #[serde(rename = "truncated")] + #[serde(default = "default_truncated")] pub truncated: bool, /// Serialised payload size in bytes. #[serde(rename = "bytes")] + #[serde(default = "default_bytes")] pub bytes: i64, } +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_row_count() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_duration_ms() -> i64 { + 0 +} + +fn default_truncated() -> bool { + false +} + +fn default_bytes() -> i64 { + 0 +} + impl DedicatedDatabaseExecution { /// Get rows pub fn rows(&self) -> &Vec { diff --git a/src/models/dedicated_database_execution_column.rs b/src/models/dedicated_database_execution_column.rs index 0ec270d..4ceffeb 100644 --- a/src/models/dedicated_database_execution_column.rs +++ b/src/models/dedicated_database_execution_column.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExecutionColumn { /// Column name as returned by the database. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Engine-specific column type (e.g. int4, text, timestamptz). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + impl DedicatedDatabaseExecutionColumn { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/dedicated_database_extensions.rs b/src/models/dedicated_database_extensions.rs index eefa389..a1a9d2f 100644 --- a/src/models/dedicated_database_extensions.rs +++ b/src/models/dedicated_database_extensions.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExtensions { /// List of installed extensions. #[serde(rename = "installed")] + #[serde(default = "default_installed")] pub installed: Vec, /// List of available extensions that can be installed. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: Vec, /// Curated metadata (display name, description, category) for each available /// extension. #[serde(rename = "metadata")] + #[serde(default = "default_metadata")] pub metadata: Vec, } +fn default_installed() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_available() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_metadata() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseExtensions { /// Get installed pub fn installed(&self) -> &Vec { diff --git a/src/models/dedicated_database_list.rs b/src/models/dedicated_database_list.rs index 7c68b07..40a0892 100644 --- a/src/models/dedicated_database_list.rs +++ b/src/models/dedicated_database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_member.rs b/src/models/dedicated_database_member.rs index df7f0d1..9ab4fee 100644 --- a/src/models/dedicated_database_member.rs +++ b/src/models/dedicated_database_member.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseMember { /// Member identifier. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology and this member has not /// been probed, so no member can be named the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Member pod status. Possible values: pending (configured but absent from the /// backend topology, so nothing is bringing it up), provisioning (pod missing @@ -21,6 +23,7 @@ pub struct DedicatedDatabaseMember { /// failed (Failed phase or CrashLoopBackOff container), or the lowercased pod /// phase reported by the cluster. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -41,6 +44,18 @@ pub struct DedicatedDatabaseMember { pub lag_seconds: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl DedicatedDatabaseMember { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation.rs b/src/models/dedicated_database_operation.rs index 4476b00..02c317c 100644 --- a/src/models/dedicated_database_operation.rs +++ b/src/models/dedicated_database_operation.rs @@ -8,24 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperation { /// Operation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Operation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID the operation ran against. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Operation type, such as provision, update, credentials-update, restore, /// pausing, resuming, failover, backup-create or cross-region-enable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Operation status. Possible values: queued (accepted and waiting to resume), /// running (in progress), completed (finished successfully), failed (ended in /// an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of times this operation has been attempted. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, /// Time the operation was requested, in ISO 8601 format. #[serde(rename = "requestedAt")] @@ -42,12 +48,46 @@ pub struct DedicatedDatabaseOperation { /// Machine-readable failure code. `Interrupted` marks an attempt that ended /// before its outcome could be confirmed. #[serde(rename = "errorCode")] + #[serde(default = "default_error_code")] pub error_code: String, /// Failure message if the operation failed. #[serde(rename = "errorMessage")] + #[serde(default = "default_error_message")] pub error_message: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + +fn default_error_code() -> String { + "".to_string() +} + +fn default_error_message() -> String { + "".to_string() +} + impl DedicatedDatabaseOperation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation_list.rs b/src/models/dedicated_database_operation_list.rs index 641721c..de4eb57 100644 --- a/src/models/dedicated_database_operation_list.rs +++ b/src/models/dedicated_database_operation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperationList { /// Total number of operations. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of operations. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_operations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseOperationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_pitr_windows.rs b/src/models/dedicated_database_pitr_windows.rs index 52b2fe5..59240b4 100644 --- a/src/models/dedicated_database_pitr_windows.rs +++ b/src/models/dedicated_database_pitr_windows.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePITRWindows { /// Earliest available recovery point. #[serde(rename = "earliest")] + #[serde(default = "default_earliest")] pub earliest: String, /// Latest available recovery point. #[serde(rename = "latest")] + #[serde(default = "default_latest")] pub latest: String, } +fn default_earliest() -> String { + "".to_string() +} + +fn default_latest() -> String { + "".to_string() +} + impl DedicatedDatabasePITRWindows { /// Get earliest pub fn earliest(&self) -> &String { diff --git a/src/models/dedicated_database_pooler.rs b/src/models/dedicated_database_pooler.rs index d1fa674..2d23de5 100644 --- a/src/models/dedicated_database_pooler.rs +++ b/src/models/dedicated_database_pooler.rs @@ -8,49 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePooler { /// Whether connection pooling is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Connection pool mode. Possible values: transaction (releases connections /// back to pool after each transaction), session (holds connections for the /// entire client session). #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Client-connection ceiling the pooler accepts. Enforced on MySQL and /// MariaDB; on PostgreSQL the pooler has no client cap, so this reports the /// database's advertised networkMaxConnections and cannot be set here. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Default pool size per user. #[serde(rename = "defaultPoolSize")] + #[serde(default = "default_default_pool_size")] pub default_pool_size: i64, /// Pooler listening port. #[serde(rename = "port")] + #[serde(default = "default_port")] pub port: i64, /// Whether SELECTs are routed to HA replicas while writes and locked reads /// stay on the primary. Active only when HA is enabled. #[serde(rename = "readWriteSplitting")] + #[serde(default = "default_read_write_splitting")] pub read_write_splitting: bool, /// Effective CPU request applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (5% of DB CPU, floor 100m) /// unless overridden. #[serde(rename = "poolerCpuRequest")] + #[serde(default = "default_pooler_cpu_request")] pub pooler_cpu_request: String, /// Effective CPU limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (10% of DB CPU, floor 200m) /// unless overridden. #[serde(rename = "poolerCpuLimit")] + #[serde(default = "default_pooler_cpu_limit")] pub pooler_cpu_limit: String, /// Effective memory request applied to the pooler sidecar container /// (Kubernetes quantity). Returns the proportional default (7.5% of DB memory, /// floor 64Mi) unless overridden. #[serde(rename = "poolerMemoryRequest")] + #[serde(default = "default_pooler_memory_request")] pub pooler_memory_request: String, /// Effective memory limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (15% of DB memory, floor 128Mi) /// unless overridden. #[serde(rename = "poolerMemoryLimit")] + #[serde(default = "default_pooler_memory_limit")] pub pooler_memory_limit: String, } +fn default_enabled() -> bool { + false +} + +fn default_mode() -> String { + "transaction".to_string() +} + +fn default_max_connections() -> i64 { + 100 +} + +fn default_default_pool_size() -> i64 { + 20 +} + +fn default_port() -> i64 { + 6432 +} + +fn default_read_write_splitting() -> bool { + false +} + +fn default_pooler_cpu_request() -> String { + "".to_string() +} + +fn default_pooler_cpu_limit() -> String { + "".to_string() +} + +fn default_pooler_memory_request() -> String { + "".to_string() +} + +fn default_pooler_memory_limit() -> String { + "".to_string() +} + impl DedicatedDatabasePooler { /// Get enabled pub fn enabled(&self) -> &bool { diff --git a/src/models/dedicated_database_replicas.rs b/src/models/dedicated_database_replicas.rs index 24bd468..701d8cc 100644 --- a/src/models/dedicated_database_replicas.rs +++ b/src/models/dedicated_database_replicas.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseReplicas { /// Number of configured replicas. Zero means high availability is disabled. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Requested replication sync mode. Possible values: async (asynchronous, /// fastest), sync (synchronous, strong consistency), quorum (quorum-based, /// majority of replicas must confirm). This is what was asked for; compare it /// with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. A value below the @@ -24,13 +26,16 @@ pub struct DedicatedDatabaseReplicas { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. Zero means writes are acknowledged locally. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -48,9 +53,34 @@ pub struct DedicatedDatabaseReplicas { pub sync_state_confirmed: Option, /// Per-pod statuses for the primary and every replica. #[serde(rename = "members")] + #[serde(default = "default_members")] pub members: Vec, } +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_members() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseReplicas { /// Get replicas pub fn replicas(&self) -> &i64 { diff --git a/src/models/dedicated_database_restoration.rs b/src/models/dedicated_database_restoration.rs index e52fefd..0af230f 100644 --- a/src/models/dedicated_database_restoration.rs +++ b/src/models/dedicated_database_restoration.rs @@ -8,45 +8,97 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID being restored into. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Source database ID when restoring a backup into another database. #[serde(rename = "sourceDatabaseId")] - pub source_database_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_database_id: Option, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup ID used for restoration (null for PITR). #[serde(rename = "backupId")] - pub backup_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub backup_id: Option, /// Restoration type. Possible values: backup (restore from a specific backup /// snapshot), pitr (point-in-time recovery to a specific timestamp). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, + /// Where the backup was restored. Possible values: in_place (replayed over the + /// database that took the backup), clone (recovered onto a second workload + /// beside the database, which keeps serving until the clone is promoted onto + /// its endpoint), copy (recovered onto a separate database with its own + /// endpoint). + #[serde(rename = "restoreMode")] + #[serde(default = "default_restore_mode")] + pub restore_mode: String, /// Restoration status. Possible values: pending (queued for processing), /// running (currently in progress), completed (successfully finished), failed /// (encountered an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Target time for PITR restoration in ISO 8601 format. #[serde(rename = "targetTime")] - pub target_time: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_time: Option, /// Restoration start time in ISO 8601 format. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Restoration completion time in ISO 8601 format. #[serde(rename = "completedAt")] - pub completed_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub completed_at: Option, /// Error message if restoration failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "backup".to_string() +} + +fn default_restore_mode() -> String { + "in_place".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseRestoration { /// Get id pub fn id(&self) -> &String { @@ -63,9 +115,15 @@ impl DedicatedDatabaseRestoration { &self.database_id } + /// Set source_database_id + pub fn set_source_database_id(mut self, source_database_id: String) -> Self { + self.source_database_id = Some(source_database_id); + self + } + /// Get source_database_id - pub fn source_database_id(&self) -> &String { - &self.source_database_id + pub fn source_database_id(&self) -> Option<&String> { + self.source_database_id.as_ref() } /// Get project_id @@ -73,9 +131,15 @@ impl DedicatedDatabaseRestoration { &self.project_id } + /// Set backup_id + pub fn set_backup_id(mut self, backup_id: String) -> Self { + self.backup_id = Some(backup_id); + self + } + /// Get backup_id - pub fn backup_id(&self) -> &String { - &self.backup_id + pub fn backup_id(&self) -> Option<&String> { + self.backup_id.as_ref() } /// Get r#type @@ -83,24 +147,47 @@ impl DedicatedDatabaseRestoration { &self.r#type } + /// Get restore_mode + pub fn restore_mode(&self) -> &String { + &self.restore_mode + } + /// Get status pub fn status(&self) -> &String { &self.status } + /// Set target_time + pub fn set_target_time(mut self, target_time: String) -> Self { + self.target_time = Some(target_time); + self + } + /// Get target_time - pub fn target_time(&self) -> &String { - &self.target_time + pub fn target_time(&self) -> Option<&String> { + self.target_time.as_ref() + } + + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self } /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() + } + + /// Set completed_at + pub fn set_completed_at(mut self, completed_at: String) -> Self { + self.completed_at = Some(completed_at); + self } /// Get completed_at - pub fn completed_at(&self) -> &String { - &self.completed_at + pub fn completed_at(&self) -> Option<&String> { + self.completed_at.as_ref() } /// Get error @@ -119,14 +206,10 @@ mod tests { let _ = _model.id(); let _ = _model.created_at(); let _ = _model.database_id(); - let _ = _model.source_database_id(); let _ = _model.project_id(); - let _ = _model.backup_id(); let _ = _model.r#type(); + let _ = _model.restore_mode(); let _ = _model.status(); - let _ = _model.target_time(); - let _ = _model.started_at(); - let _ = _model.completed_at(); let _ = _model.error(); } diff --git a/src/models/dedicated_database_restoration_list.rs b/src/models/dedicated_database_restoration_list.rs index 3d24d00..170ff62 100644 --- a/src/models/dedicated_database_restoration_list.rs +++ b/src/models/dedicated_database_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_specification.rs b/src/models/dedicated_database_specification.rs index 7dab746..f2bc9ee 100644 --- a/src/models/dedicated_database_specification.rs +++ b/src/models/dedicated_database_specification.rs @@ -8,49 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecification { /// Specification slug. Use this value when creating a dedicated database. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, /// Human readable specification name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Monthly price of the specification in USD. #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Price per GB of storage above the included amount, per month, in USD. #[serde(rename = "storageOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_overage_rate: Option, + #[serde(default = "default_storage_overage_rate")] + pub storage_overage_rate: f64, /// Price per GB of bandwidth above the included amount, per month, in USD. #[serde(rename = "bandwidthOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub bandwidth_overage_rate: Option, + #[serde(default = "default_bandwidth_overage_rate")] + pub bandwidth_overage_rate: f64, /// High availability replica price as a fraction of the specification price. #[serde(rename = "replicaRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub replica_rate: Option, + #[serde(default = "default_replica_rate")] + pub replica_rate: f64, /// Point-in-time recovery price as a fraction of the specification price. #[serde(rename = "pitrRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pitr_rate: Option, + #[serde(default = "default_pitr_rate")] + pub pitr_rate: f64, /// Allocated CPU in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Allocated memory in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Maximum number of concurrent connections. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Included storage in GB before overage charges apply. #[serde(rename = "includedStorage")] + #[serde(default = "default_included_storage")] pub included_storage: i64, /// Included bandwidth in GB before overage charges apply. #[serde(rename = "includedBandwidth")] + #[serde(default = "default_included_bandwidth")] pub included_bandwidth: i64, /// Whether the specification is available on the current plan. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_slug() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_storage_overage_rate() -> f64 { + 0.0 +} + +fn default_bandwidth_overage_rate() -> f64 { + 0.0 +} + +fn default_replica_rate() -> f64 { + 0.0 +} + +fn default_pitr_rate() -> f64 { + 0.0 +} + +fn default_cpu() -> i64 { + 0 +} + +fn default_memory() -> i64 { + 0 +} + +fn default_max_connections() -> i64 { + 0 +} + +fn default_included_storage() -> i64 { + 0 +} + +fn default_included_bandwidth() -> i64 { + 0 +} + +fn default_enabled() -> bool { + false +} + impl DedicatedDatabaseSpecification { /// Get slug pub fn slug(&self) -> &String { @@ -67,48 +128,24 @@ impl DedicatedDatabaseSpecification { &self.price } - /// Set storage_overage_rate - pub fn set_storage_overage_rate(mut self, storage_overage_rate: f64) -> Self { - self.storage_overage_rate = Some(storage_overage_rate); - self - } - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> Option<&f64> { - self.storage_overage_rate.as_ref() - } - - /// Set bandwidth_overage_rate - pub fn set_bandwidth_overage_rate(mut self, bandwidth_overage_rate: f64) -> Self { - self.bandwidth_overage_rate = Some(bandwidth_overage_rate); - self + pub fn storage_overage_rate(&self) -> &f64 { + &self.storage_overage_rate } /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> Option<&f64> { - self.bandwidth_overage_rate.as_ref() - } - - /// Set replica_rate - pub fn set_replica_rate(mut self, replica_rate: f64) -> Self { - self.replica_rate = Some(replica_rate); - self + pub fn bandwidth_overage_rate(&self) -> &f64 { + &self.bandwidth_overage_rate } /// Get replica_rate - pub fn replica_rate(&self) -> Option<&f64> { - self.replica_rate.as_ref() - } - - /// Set pitr_rate - pub fn set_pitr_rate(mut self, pitr_rate: f64) -> Self { - self.pitr_rate = Some(pitr_rate); - self + pub fn replica_rate(&self) -> &f64 { + &self.replica_rate } /// Get pitr_rate - pub fn pitr_rate(&self) -> Option<&f64> { - self.pitr_rate.as_ref() + pub fn pitr_rate(&self) -> &f64 { + &self.pitr_rate } /// Get cpu @@ -152,6 +189,10 @@ mod tests { let _ = _model.slug(); let _ = _model.name(); let _ = _model.price(); + let _ = _model.storage_overage_rate(); + let _ = _model.bandwidth_overage_rate(); + let _ = _model.replica_rate(); + let _ = _model.pitr_rate(); let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.max_connections(); diff --git a/src/models/dedicated_database_specification_list.rs b/src/models/dedicated_database_specification_list.rs index 2be3453..e86f829 100644 --- a/src/models/dedicated_database_specification_list.rs +++ b/src/models/dedicated_database_specification_list.rs @@ -8,13 +8,20 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecificationList { /// List of dedicated database specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, /// Total number of specifications. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, - /// Overage and add-on pricing shared across all specifications. - #[serde(rename = "pricing")] - pub pricing: crate::models::DedicatedDatabaseSpecificationPricing, +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_total() -> i64 { + 0 } impl DedicatedDatabaseSpecificationList { @@ -27,11 +34,6 @@ impl DedicatedDatabaseSpecificationList { pub fn total(&self) -> &i64 { &self.total } - - /// Get pricing - pub fn pricing(&self) -> &crate::models::DedicatedDatabaseSpecificationPricing { - &self.pricing - } } #[cfg(test)] @@ -43,7 +45,6 @@ mod tests { let _model = ::default(); let _ = _model.specifications(); let _ = _model.total(); - let _ = _model.pricing(); } #[test] diff --git a/src/models/dedicated_database_specification_pricing.rs b/src/models/dedicated_database_specification_pricing.rs deleted file mode 100644 index 0842526..0000000 --- a/src/models/dedicated_database_specification_pricing.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! DedicatedDatabaseSpecificationPricing model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// SpecificationPricing -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DedicatedDatabaseSpecificationPricing { - /// Price per GB of storage above the included amount, per month, in USD. - #[serde(rename = "storageOverageRate")] - pub storage_overage_rate: f64, - /// Price per GB of bandwidth above the included amount, per month, in USD. - #[serde(rename = "bandwidthOverageRate")] - pub bandwidth_overage_rate: f64, - /// High availability replica price as a fraction of the specification cost. - #[serde(rename = "replicaRate")] - pub replica_rate: f64, - /// Point-in-time recovery price as a fraction of the specification cost. - #[serde(rename = "pitrRate")] - pub pitr_rate: f64, -} - -impl DedicatedDatabaseSpecificationPricing { - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> &f64 { - &self.storage_overage_rate - } - - /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> &f64 { - &self.bandwidth_overage_rate - } - - /// Get replica_rate - pub fn replica_rate(&self) -> &f64 { - &self.replica_rate - } - - /// Get pitr_rate - pub fn pitr_rate(&self) -> &f64 { - &self.pitr_rate - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dedicated_database_specification_pricing_creation() { - let _model = ::default(); - let _ = _model.storage_overage_rate(); - let _ = _model.bandwidth_overage_rate(); - let _ = _model.replica_rate(); - let _ = _model.pitr_rate(); - } - - #[test] - fn test_dedicated_database_specification_pricing_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = - serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/deployment.rs b/src/models/deployment.rs index 2da7e6f..78539b5 100644 --- a/src/models/deployment.rs +++ b/src/models/deployment.rs @@ -8,45 +8,59 @@ use serde::{Deserialize, Serialize}; pub struct Deployment { /// Deployment ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Deployment creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Deployment update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Type of deployment. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// The entrypoint file to use to execute the deployment code. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The code size in bytes. #[serde(rename = "sourceSize")] + #[serde(default = "default_source_size")] pub source_size: i64, /// The build output size in bytes. #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// The total size in bytes (source and build output). #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, /// The current build ID. #[serde(rename = "buildId")] + #[serde(default = "default_build_id")] pub build_id: String, /// Whether the deployment should be automatically activated. #[serde(rename = "activate")] + #[serde(default = "default_activate")] pub activate: bool, /// Screenshot with light theme preference file ID. #[serde(rename = "screenshotLight")] + #[serde(default = "default_screenshot_light")] pub screenshot_light: String, /// Screenshot with dark theme preference file ID. #[serde(rename = "screenshotDark")] + #[serde(default = "default_screenshot_dark")] pub screenshot_dark: String, /// The deployment status. Possible values are "waiting", "processing", /// "building", "ready", "canceled" and "failed". @@ -54,42 +68,158 @@ pub struct Deployment { pub status: crate::enums::DeploymentStatus, /// The build logs. #[serde(rename = "buildLogs")] + #[serde(default = "default_build_logs")] pub build_logs: String, /// The current build time in seconds. #[serde(rename = "buildDuration")] + #[serde(default = "default_build_duration")] pub build_duration: i64, /// The name of the vcs provider repository #[serde(rename = "providerRepositoryName")] + #[serde(default = "default_provider_repository_name")] pub provider_repository_name: String, /// The name of the vcs provider repository owner #[serde(rename = "providerRepositoryOwner")] + #[serde(default = "default_provider_repository_owner")] pub provider_repository_owner: String, /// The url of the vcs provider repository #[serde(rename = "providerRepositoryUrl")] + #[serde(default = "default_provider_repository_url")] pub provider_repository_url: String, /// The commit hash of the vcs commit #[serde(rename = "providerCommitHash")] + #[serde(default = "default_provider_commit_hash")] pub provider_commit_hash: String, /// The url of vcs commit author #[serde(rename = "providerCommitAuthorUrl")] + #[serde(default = "default_provider_commit_author_url")] pub provider_commit_author_url: String, /// The name of vcs commit author #[serde(rename = "providerCommitAuthor")] + #[serde(default = "default_provider_commit_author")] pub provider_commit_author: String, /// The commit message #[serde(rename = "providerCommitMessage")] + #[serde(default = "default_provider_commit_message")] pub provider_commit_message: String, /// The url of the vcs commit #[serde(rename = "providerCommitUrl")] + #[serde(default = "default_provider_commit_url")] pub provider_commit_url: String, /// The branch of the vcs repository #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// The branch of the vcs repository #[serde(rename = "providerBranchUrl")] + #[serde(default = "default_provider_branch_url")] pub provider_branch_url: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_source_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_total_size() -> i64 { + 0 +} + +fn default_build_id() -> String { + "".to_string() +} + +fn default_activate() -> bool { + false +} + +fn default_screenshot_light() -> String { + "".to_string() +} + +fn default_screenshot_dark() -> String { + "".to_string() +} + +fn default_build_logs() -> String { + "".to_string() +} + +fn default_build_duration() -> i64 { + 0 +} + +fn default_provider_repository_name() -> String { + "".to_string() +} + +fn default_provider_repository_owner() -> String { + "".to_string() +} + +fn default_provider_repository_url() -> String { + "".to_string() +} + +fn default_provider_commit_hash() -> String { + "".to_string() +} + +fn default_provider_commit_author_url() -> String { + "".to_string() +} + +fn default_provider_commit_author() -> String { + "".to_string() +} + +fn default_provider_commit_message() -> String { + "".to_string() +} + +fn default_provider_commit_url() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_branch_url() -> String { + "".to_string() +} + impl Deployment { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/deployment_list.rs b/src/models/deployment_list.rs index 5ee6ea7..f58b0b2 100644 --- a/src/models/deployment_list.rs +++ b/src/models/deployment_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DeploymentList { /// Total number of deployments that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of deployments. #[serde(rename = "deployments")] + #[serde(default = "default_deployments")] pub deployments: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_deployments() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DeploymentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dev_key.rs b/src/models/dev_key.rs deleted file mode 100644 index 7b5ba1f..0000000 --- a/src/models/dev_key.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! DevKey model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// DevKey -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DevKey { - /// Key ID. - #[serde(rename = "$id")] - pub id: String, - /// Key creation date in ISO 8601 format. - #[serde(rename = "$createdAt")] - pub created_at: String, - /// Key update date in ISO 8601 format. - #[serde(rename = "$updatedAt")] - pub updated_at: String, - /// Key name. - #[serde(rename = "name")] - pub name: String, - /// Key expiration date in ISO 8601 format. - #[serde(rename = "expire")] - pub expire: String, - /// Secret key. - #[serde(rename = "secret")] - pub secret: String, - /// Most recent access date in ISO 8601 format. This attribute is only updated - /// again after 24 hours. - #[serde(rename = "accessedAt")] - pub accessed_at: String, - /// List of SDK user agents that used this key. - #[serde(rename = "sdks")] - pub sdks: Vec, -} - -impl DevKey { - /// Get id - pub fn id(&self) -> &String { - &self.id - } - - /// Get created_at - pub fn created_at(&self) -> &String { - &self.created_at - } - - /// Get updated_at - pub fn updated_at(&self) -> &String { - &self.updated_at - } - - /// Get name - pub fn name(&self) -> &String { - &self.name - } - - /// Get expire - pub fn expire(&self) -> &String { - &self.expire - } - - /// Get secret - pub fn secret(&self) -> &String { - &self.secret - } - - /// Get accessed_at - pub fn accessed_at(&self) -> &String { - &self.accessed_at - } - - /// Get sdks - pub fn sdks(&self) -> &Vec { - &self.sdks - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dev_key_creation() { - let _model = ::default(); - let _ = _model.id(); - let _ = _model.created_at(); - let _ = _model.updated_at(); - let _ = _model.name(); - let _ = _model.expire(); - let _ = _model.secret(); - let _ = _model.accessed_at(); - let _ = _model.sdks(); - } - - #[test] - fn test_dev_key_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/document.rs b/src/models/document.rs index 67c4a9c..0976976 100644 --- a/src/models/document.rs +++ b/src/models/document.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Document { /// Document ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Document sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Collection ID. #[serde(rename = "$collectionId")] + #[serde(default = "default_collection_id")] pub collection_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Document creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Document update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Document permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_collection_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Document { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/document_list.rs b/src/models/document_list.rs index bf9ba60..55f3143 100644 --- a/src/models/document_list.rs +++ b/src/models/document_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DocumentList { /// Total number of documents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of documents. #[serde(rename = "documents")] + #[serde(default = "default_documents")] pub documents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_documents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DocumentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/email_template.rs b/src/models/email_template.rs index 3236650..4ff064a 100644 --- a/src/models/email_template.rs +++ b/src/models/email_template.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplate { /// Template type #[serde(rename = "templateId")] + #[serde(default = "default_template_id")] pub template_id: String, /// Template locale #[serde(rename = "locale")] + #[serde(default = "default_locale")] pub locale: String, /// Template message #[serde(rename = "message")] + #[serde(default = "default_message")] pub message: String, /// Name of the sender #[serde(rename = "senderName")] + #[serde(default = "default_sender_name")] pub sender_name: String, /// Email of the sender #[serde(rename = "senderEmail")] + #[serde(default = "default_sender_email")] pub sender_email: String, /// Reply to email address #[serde(rename = "replyToEmail")] + #[serde(default = "default_reply_to_email")] pub reply_to_email: String, /// Reply to name #[serde(rename = "replyToName")] + #[serde(default = "default_reply_to_name")] pub reply_to_name: String, /// Email subject #[serde(rename = "subject")] + #[serde(default = "default_subject")] pub subject: String, } +fn default_template_id() -> String { + "".to_string() +} + +fn default_locale() -> String { + "".to_string() +} + +fn default_message() -> String { + "".to_string() +} + +fn default_sender_name() -> String { + "".to_string() +} + +fn default_sender_email() -> String { + "".to_string() +} + +fn default_reply_to_email() -> String { + "".to_string() +} + +fn default_reply_to_name() -> String { + "".to_string() +} + +fn default_subject() -> String { + "".to_string() +} + impl EmailTemplate { /// Get template_id pub fn template_id(&self) -> &String { diff --git a/src/models/email_template_list.rs b/src/models/email_template_list.rs index 02dbf9a..6d93da2 100644 --- a/src/models/email_template_list.rs +++ b/src/models/email_template_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplateList { /// Total number of templates that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of templates. #[serde(rename = "templates")] + #[serde(default = "default_templates")] pub templates: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_templates() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmailTemplateList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/embedding.rs b/src/models/embedding.rs index 1e26677..041e14d 100644 --- a/src/models/embedding.rs +++ b/src/models/embedding.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Embedding { /// Embedding model used to generate embeddings. #[serde(rename = "model")] + #[serde(default = "default_model")] pub model: String, /// Number of dimensions for each embedding vector. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, /// Embedding vector values. If an error occurs, this will be an empty array. #[serde(rename = "embedding")] + #[serde(default = "default_embedding")] pub embedding: Vec, /// Error message if embedding generation fails. Empty string if no error. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_model() -> String { + "".to_string() +} + +fn default_dimension() -> i64 { + 0 +} + +fn default_embedding() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_error() -> String { + "".to_string() +} + impl Embedding { /// Get model pub fn model(&self) -> &String { diff --git a/src/models/embedding_list.rs b/src/models/embedding_list.rs index 65f3074..25c9cbf 100644 --- a/src/models/embedding_list.rs +++ b/src/models/embedding_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmbeddingList { /// Total number of embeddings that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of embeddings. #[serde(rename = "embeddings")] + #[serde(default = "default_embeddings")] pub embeddings: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_embeddings() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmbeddingList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/ephemeral_key.rs b/src/models/ephemeral_key.rs index 091da9c..6abef19 100644 --- a/src/models/ephemeral_key.rs +++ b/src/models/ephemeral_key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct EphemeralKey { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EphemeralKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution.rs b/src/models/execution.rs index 9591343..72ace97 100644 --- a/src/models/execution.rs +++ b/src/models/execution.rs @@ -8,27 +8,34 @@ use serde::{Deserialize, Serialize}; pub struct Execution { /// Execution ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Execution creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Execution update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution roles. #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Function or site ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Execution resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: crate::enums::ExecutionResourceType, /// Deployment ID used to create the execution. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// The trigger that caused the resource to execute. Possible values can be: - /// `http`, `schedule`, or `event`. + /// `http`, `schedule`, `event`, or `email`. #[serde(rename = "trigger")] pub trigger: crate::enums::ExecutionTrigger, /// The status of the resource execution. Possible values can be: `waiting`, @@ -37,39 +44,48 @@ pub struct Execution { pub status: crate::enums::ExecutionStatus, /// HTTP request method type. #[serde(rename = "requestMethod")] + #[serde(default = "default_request_method")] pub request_method: String, /// HTTP request path and query. #[serde(rename = "requestPath")] + #[serde(default = "default_request_path")] pub request_path: String, /// HTTP request headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "requestHeaders")] + #[serde(default = "default_request_headers")] pub request_headers: Vec, /// HTTP response status code. #[serde(rename = "responseStatusCode")] + #[serde(default = "default_response_status_code")] pub response_status_code: i64, /// HTTP response body. This will return empty unless execution is created as /// synchronous. #[serde(rename = "responseBody")] + #[serde(default = "default_response_body")] pub response_body: String, /// HTTP response headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "responseHeaders")] + #[serde(default = "default_response_headers")] pub response_headers: Vec, /// Resource logs. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Resource errors. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "errors")] + #[serde(default = "default_errors")] pub errors: String, - /// Resource(function/site) execution duration in seconds. + /// Total time the resource(function/site) took to respond, in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: f64, /// The scheduled time for execution. If left empty, execution will be queued /// immediately. @@ -78,6 +94,70 @@ pub struct Execution { pub scheduled_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> crate::enums::ExecutionResourceType { + serde_json::from_value(serde_json::json!("functions")).unwrap() +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_request_method() -> String { + "".to_string() +} + +fn default_request_path() -> String { + "".to_string() +} + +fn default_request_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_response_status_code() -> i64 { + 0 +} + +fn default_response_body() -> String { + "".to_string() +} + +fn default_response_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_errors() -> String { + "".to_string() +} + +fn default_duration() -> f64 { + 0.0 +} + impl Execution { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution_list.rs b/src/models/execution_list.rs index 85fa76f..d30bc6c 100644 --- a/src/models/execution_list.rs +++ b/src/models/execution_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ExecutionList { /// Total number of executions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of executions. #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_executions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ExecutionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/file.rs b/src/models/file.rs index 1310f94..1f95426 100644 --- a/src/models/file.rs +++ b/src/models/file.rs @@ -8,58 +8,138 @@ use serde::{Deserialize, Serialize}; pub struct File { /// File ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket ID. #[serde(rename = "bucketId")] + #[serde(default = "default_bucket_id")] pub bucket_id: String, /// File creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// File update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// File permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// File name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Virtual folder containing the file, with a trailing slash. Empty for the /// bucket root. #[serde(rename = "folder")] + #[serde(default = "default_folder")] pub folder: String, /// Full virtual path of the file: the folder followed by the file name. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// File MD5 signature. #[serde(rename = "signature")] + #[serde(default = "default_signature")] pub signature: String, /// File mime type. #[serde(rename = "mimeType")] + #[serde(default = "default_mime_type")] pub mime_type: String, /// File original size in bytes. #[serde(rename = "sizeOriginal")] + #[serde(default = "default_size_original")] pub size_original: i64, /// File actual stored size in bytes after compression and/or encryption. #[serde(rename = "sizeActual")] + #[serde(default = "default_size_actual")] pub size_actual: i64, /// Total number of chunks available #[serde(rename = "chunksTotal")] + #[serde(default = "default_chunks_total")] pub chunks_total: i64, /// Total number of chunks uploaded #[serde(rename = "chunksUploaded")] + #[serde(default = "default_chunks_uploaded")] pub chunks_uploaded: i64, /// Whether file contents are encrypted at rest. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Compression algorithm used for the file. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_bucket_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_folder() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_signature() -> String { + "".to_string() +} + +fn default_mime_type() -> String { + "".to_string() +} + +fn default_size_original() -> i64 { + 0 +} + +fn default_size_actual() -> i64 { + 0 +} + +fn default_chunks_total() -> i64 { + 0 +} + +fn default_chunks_uploaded() -> i64 { + 0 +} + +fn default_encryption() -> bool { + false +} + +fn default_compression() -> String { + "none".to_string() +} + impl File { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/file_list.rs b/src/models/file_list.rs index bc9f598..06a0bec 100644 --- a/src/models/file_list.rs +++ b/src/models/file_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FileList { /// Total number of files that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of files. #[serde(rename = "files")] + #[serde(default = "default_files")] pub files: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_files() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FileList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/framework.rs b/src/models/framework.rs index fbc7a82..2f04803 100644 --- a/src/models/framework.rs +++ b/src/models/framework.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct Framework { /// Framework key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Framework Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Default runtime version. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// List of supported runtime versions. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, /// List of supported adapters. #[serde(rename = "adapters")] + #[serde(default = "default_adapters")] pub adapters: Vec, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_adapters() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Framework { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_adapter.rs b/src/models/framework_adapter.rs index 5ffe882..d945c32 100644 --- a/src/models/framework_adapter.rs +++ b/src/models/framework_adapter.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkAdapter { /// Adapter key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Default command to download dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// Default command to build site into output directory. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Default output directory of build. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Name of fallback file to use instead of 404 page. If null, Appwrite 404 /// page will be displayed. @@ -25,6 +29,22 @@ pub struct FrameworkAdapter { pub fallback_file: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + impl FrameworkAdapter { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_list.rs b/src/models/framework_list.rs index 9d8570f..fd7e484 100644 --- a/src/models/framework_list.rs +++ b/src/models/framework_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkList { /// Total number of frameworks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of frameworks. #[serde(rename = "frameworks")] + #[serde(default = "default_frameworks")] pub frameworks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_frameworks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FrameworkList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/function.rs b/src/models/function.rs index 06374cd..e67616e 100644 --- a/src/models/function.rs +++ b/src/models/function.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct Function { /// Function ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Function creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Function update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution permissions. #[serde(rename = "execute")] + #[serde(default = "default_execute")] pub execute: Vec, /// Function name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Function enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the function deployed with the latest configuration? This is set to /// false if you've changed an environment variables, entrypoint, commands, or /// other settings that needs redeploy to be applied. When the value is false, /// redeploy the function to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, executions will exclude logs and errors, and will be /// slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Function execution and build runtime. #[serde(rename = "runtime")] + #[serde(default = "default_runtime")] pub runtime: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Function's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Function's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Function variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Function trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Function execution schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Minutes between scheduled executions. 0 when the function has no interval. #[serde(rename = "interval")] @@ -75,47 +94,193 @@ pub struct Function { pub interval: Option, /// Function execution timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The entrypoint file used to execute the deployment. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The build command used to build the deployment. #[serde(rename = "commands")] + #[serde(default = "default_commands")] pub commands: String, /// Version of Open Runtimes used for the function. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Function VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to function in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, + /// Whether inbound email (SMTP) may trigger this function. Opt-in; default is + /// false. When disabled, recipients for this function are rejected. + #[serde(rename = "emailEnabled")] + #[serde(skip_serializing_if = "Option::is_none")] + pub email_enabled: Option, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_execute() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_runtime() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_schedule() -> String { + "".to_string() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_commands() -> String { + "".to_string() +} + +fn default_version() -> String { + "v5".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() } impl Function { @@ -289,6 +454,17 @@ impl Function { pub fn runtime_specification(&self) -> &String { &self.runtime_specification } + + /// Set email_enabled + pub fn set_email_enabled(mut self, email_enabled: bool) -> Self { + self.email_enabled = Some(email_enabled); + self + } + + /// Get email_enabled + pub fn email_enabled(&self) -> Option<&bool> { + self.email_enabled.as_ref() + } } #[cfg(test)] diff --git a/src/models/function_list.rs b/src/models/function_list.rs index ff9a37d..ee30315 100644 --- a/src/models/function_list.rs +++ b/src/models/function_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FunctionList { /// Total number of functions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of functions. #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_functions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FunctionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/headers.rs b/src/models/headers.rs index 87a2b64..2aed2bc 100644 --- a/src/models/headers.rs +++ b/src/models/headers.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Headers { /// Header name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Header value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + impl Headers { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/identity.rs b/src/models/identity.rs index aca8541..bc00cf8 100644 --- a/src/models/identity.rs +++ b/src/models/identity.rs @@ -8,39 +8,93 @@ use serde::{Deserialize, Serialize}; pub struct Identity { /// Identity ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Identity creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Identity update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Identity Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// ID of the User in the Identity Provider. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Email of the User in the Identity Provider. #[serde(rename = "providerEmail")] + #[serde(default = "default_provider_email")] pub provider_email: String, /// Identity Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Identity Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// Identity Provider ID token (JWT) from the most recent native sign-in. Empty /// for identities created through the browser OAuth2 flow. #[serde(rename = "providerIdToken")] - #[serde(skip_serializing_if = "Option::is_none")] - pub provider_id_token: Option, + #[serde(default = "default_provider_id_token")] + pub provider_id_token: String, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_email() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_provider_id_token() -> String { + "".to_string() } impl Identity { @@ -94,15 +148,9 @@ impl Identity { &self.provider_refresh_token } - /// Set provider_id_token - pub fn set_provider_id_token(mut self, provider_id_token: String) -> Self { - self.provider_id_token = Some(provider_id_token); - self - } - /// Get provider_id_token - pub fn provider_id_token(&self) -> Option<&String> { - self.provider_id_token.as_ref() + pub fn provider_id_token(&self) -> &String { + &self.provider_id_token } } @@ -123,6 +171,7 @@ mod tests { let _ = _model.provider_access_token(); let _ = _model.provider_access_token_expiry(); let _ = _model.provider_refresh_token(); + let _ = _model.provider_id_token(); } #[test] diff --git a/src/models/identity_list.rs b/src/models/identity_list.rs index b8cca8a..951990d 100644 --- a/src/models/identity_list.rs +++ b/src/models/identity_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IdentityList { /// Total number of identities that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of identities. #[serde(rename = "identities")] + #[serde(default = "default_identities")] pub identities: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_identities() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IdentityList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/index.rs b/src/models/index.rs index d18b386..b3865e8 100644 --- a/src/models/index.rs +++ b/src/models/index.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Index { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -28,12 +33,15 @@ pub struct Index { /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Index attributes length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +49,38 @@ pub struct Index { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Index { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/index_list.rs b/src/models/index_list.rs index 48eec9e..39499dc 100644 --- a/src/models/index_list.rs +++ b/src/models/index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/insight.rs b/src/models/insight.rs index 937d6f7..e514aca 100644 --- a/src/models/insight.rs +++ b/src/models/insight.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct Insight { /// Insight ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Insight creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Insight update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Parent report ID. Insights always belong to a report. #[serde(rename = "reportId")] + #[serde(default = "default_report_id")] pub report_id: String, /// Insight type. One of databaseIndex (legacy), tablesDBIndex, /// documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, @@ -25,36 +29,46 @@ pub struct Insight { /// (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or /// vectorsDB.createIndex). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Insight severity. One of info, warning, critical. #[serde(rename = "severity")] + #[serde(default = "default_severity")] pub severity: String, /// Insight status. One of active, dismissed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Type of the resource the insight is about. Plural noun, e.g. databases, /// sites, functions. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of the resource the insight is about. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Plural noun for the parent resource that contains the insight's resource, /// e.g. an insight about a column index on a table → resourceType=indexes, /// parentResourceType=tables. Empty when the resource has no parent. #[serde(rename = "parentResourceType")] + #[serde(default = "default_parent_resource_type")] pub parent_resource_type: String, /// ID of the parent resource. Empty when the resource has no parent. #[serde(rename = "parentResourceId")] + #[serde(default = "default_parent_resource_id")] pub parent_resource_id: String, /// Insight title. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Short markdown summary describing the insight. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// List of call-to-action buttons attached to this insight. #[serde(rename = "ctas")] + #[serde(default = "default_ctas")] pub ctas: Vec, /// Time the insight was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -71,6 +85,62 @@ pub struct Insight { pub dismissed_by: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_report_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_severity() -> String { + "info".to_string() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_parent_resource_type() -> String { + "".to_string() +} + +fn default_parent_resource_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_ctas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Insight { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/insight_cta.rs b/src/models/insight_cta.rs index 6a3b719..d96fa8a 100644 --- a/src/models/insight_cta.rs +++ b/src/models/insight_cta.rs @@ -8,24 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct InsightCTA { /// Human-readable label for the CTA, used in UI. #[serde(rename = "label")] + #[serde(default = "default_label")] pub label: String, /// Public API service (SDK namespace) the client should invoke. Must match the /// engine that owns the resource — for index suggestions: databases /// (legacy), tablesDB, documentsDB, or vectorsDB. #[serde(rename = "service")] + #[serde(default = "default_service")] pub service: String, /// Public API method on the chosen service the client should invoke when this /// CTA is triggered. #[serde(rename = "method")] + #[serde(default = "default_method")] pub method: String, /// Parameter map the client should pass to the service method when this CTA is /// triggered. Keys match the target API's parameter names (e.g. /// databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes /// for the legacy Databases API). #[serde(rename = "params")] + #[serde(default = "default_params")] pub params: serde_json::Value, } +fn default_label() -> String { + "".to_string() +} + +fn default_service() -> String { + "".to_string() +} + +fn default_method() -> String { + "".to_string() +} + +fn default_params() -> serde_json::Value { + serde_json::json!({}) +} + impl InsightCTA { /// Get label pub fn label(&self) -> &String { diff --git a/src/models/insight_list.rs b/src/models/insight_list.rs index 54b229c..e5b6d1a 100644 --- a/src/models/insight_list.rs +++ b/src/models/insight_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct InsightList { /// Total number of insights that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of insights. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl InsightList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/jwt.rs b/src/models/jwt.rs index 8482207..535cf61 100644 --- a/src/models/jwt.rs +++ b/src/models/jwt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Jwt { /// JWT encoded string. #[serde(rename = "jwt")] + #[serde(default = "default_jwt")] pub jwt: String, } +fn default_jwt() -> String { + "".to_string() +} + impl Jwt { /// Get jwt pub fn jwt(&self) -> &String { diff --git a/src/models/key.rs b/src/models/key.rs index 109b8d5..06b83c7 100644 --- a/src/models/key.rs +++ b/src/models/key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct Key { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Key { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/key_list.rs b/src/models/key_list.rs index 0cad143..767cf5e 100644 --- a/src/models/key_list.rs +++ b/src/models/key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct KeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl KeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/language.rs b/src/models/language.rs index bef7ec4..fd3d530 100644 --- a/src/models/language.rs +++ b/src/models/language.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Language { /// Language name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Language two-character ISO 639-1 codes. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Language native name. #[serde(rename = "nativeName")] + #[serde(default = "default_native_name")] pub native_name: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + +fn default_native_name() -> String { + "".to_string() +} + impl Language { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/language_list.rs b/src/models/language_list.rs index 42d79d9..9993952 100644 --- a/src/models/language_list.rs +++ b/src/models/language_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LanguageList { /// Total number of languages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of languages. #[serde(rename = "languages")] + #[serde(default = "default_languages")] pub languages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_languages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LanguageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/locale.rs b/src/models/locale.rs index 08b7f02..ecd0d0d 100644 --- a/src/models/locale.rs +++ b/src/models/locale.rs @@ -8,28 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Locale { /// User IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) /// two-character format #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. This field support localization. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. A two character continent code "AF" for Africa, "AN" for /// Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" /// for Oceania, and "SA" for South America. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// Continent name. This field support localization. #[serde(rename = "continent")] + #[serde(default = "default_continent")] pub continent: String, /// True if country is part of the European Union. #[serde(rename = "eu")] + #[serde(default = "default_eu")] pub eu: bool, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// City #[serde(rename = "city")] @@ -77,6 +84,34 @@ pub struct Locale { pub connection_organization: Option, } +fn default_ip() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_continent() -> String { + "".to_string() +} + +fn default_eu() -> bool { + false +} + +fn default_currency() -> String { + "".to_string() +} + impl Locale { /// Get ip pub fn ip(&self) -> &String { diff --git a/src/models/locale_code.rs b/src/models/locale_code.rs index 389f8a2..84b8601 100644 --- a/src/models/locale_code.rs +++ b/src/models/locale_code.rs @@ -9,12 +9,22 @@ pub struct LocaleCode { /// Locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Locale name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + impl LocaleCode { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/locale_code_list.rs b/src/models/locale_code_list.rs index e8e2ebb..8314d75 100644 --- a/src/models/locale_code_list.rs +++ b/src/models/locale_code_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LocaleCodeList { /// Total number of localeCodes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of localeCodes. #[serde(rename = "localeCodes")] + #[serde(default = "default_locale_codes")] pub locale_codes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_locale_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LocaleCodeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/log.rs b/src/models/log.rs deleted file mode 100644 index c62709d..0000000 --- a/src/models/log.rs +++ /dev/null @@ -1,235 +0,0 @@ -//! Log model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Log -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct Log { - /// Event name. - #[serde(rename = "event")] - pub event: String, - /// User ID of the actor recorded for this log. During impersonation, this is - /// the original impersonator, not the impersonated target user. - #[serde(rename = "userId")] - pub user_id: String, - /// User email of the actor recorded for this log. During impersonation, this - /// is the original impersonator. - #[serde(rename = "userEmail")] - pub user_email: String, - /// User name of the actor recorded for this log. During impersonation, this is - /// the original impersonator. - #[serde(rename = "userName")] - pub user_name: String, - /// API mode when event triggered. - #[serde(rename = "mode")] - pub mode: String, - /// User type who triggered the audit log. Possible values: user, admin, guest, - /// hidden, keyProject, keyAccount, keyOrganization. - #[serde(rename = "userType")] - pub user_type: String, - /// IP session in use when the session was created. - #[serde(rename = "ip")] - pub ip: String, - /// Log creation date in ISO 8601 format. - #[serde(rename = "time")] - pub time: String, - /// Operating system code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - #[serde(rename = "osCode")] - pub os_code: String, - /// Operating system name. - #[serde(rename = "osName")] - pub os_name: String, - /// Operating system version. - #[serde(rename = "osVersion")] - pub os_version: String, - /// Client type. - #[serde(rename = "clientType")] - pub client_type: String, - /// Client code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - #[serde(rename = "clientCode")] - pub client_code: String, - /// Client name. - #[serde(rename = "clientName")] - pub client_name: String, - /// Client version. - #[serde(rename = "clientVersion")] - pub client_version: String, - /// Client engine name. - #[serde(rename = "clientEngine")] - pub client_engine: String, - /// Client engine name. - #[serde(rename = "clientEngineVersion")] - pub client_engine_version: String, - /// Device name. - #[serde(rename = "deviceName")] - pub device_name: String, - /// Device brand name. - #[serde(rename = "deviceBrand")] - pub device_brand: String, - /// Device model name. - #[serde(rename = "deviceModel")] - pub device_model: String, - /// Country two-character ISO 3166-1 alpha code. - #[serde(rename = "countryCode")] - pub country_code: String, - /// Country name. - #[serde(rename = "countryName")] - pub country_name: String, -} - -impl Log { - /// Get event - pub fn event(&self) -> &String { - &self.event - } - - /// Get user_id - pub fn user_id(&self) -> &String { - &self.user_id - } - - /// Get user_email - pub fn user_email(&self) -> &String { - &self.user_email - } - - /// Get user_name - pub fn user_name(&self) -> &String { - &self.user_name - } - - /// Get mode - pub fn mode(&self) -> &String { - &self.mode - } - - /// Get user_type - pub fn user_type(&self) -> &String { - &self.user_type - } - - /// Get ip - pub fn ip(&self) -> &String { - &self.ip - } - - /// Get time - pub fn time(&self) -> &String { - &self.time - } - - /// Get os_code - pub fn os_code(&self) -> &String { - &self.os_code - } - - /// Get os_name - pub fn os_name(&self) -> &String { - &self.os_name - } - - /// Get os_version - pub fn os_version(&self) -> &String { - &self.os_version - } - - /// Get client_type - pub fn client_type(&self) -> &String { - &self.client_type - } - - /// Get client_code - pub fn client_code(&self) -> &String { - &self.client_code - } - - /// Get client_name - pub fn client_name(&self) -> &String { - &self.client_name - } - - /// Get client_version - pub fn client_version(&self) -> &String { - &self.client_version - } - - /// Get client_engine - pub fn client_engine(&self) -> &String { - &self.client_engine - } - - /// Get client_engine_version - pub fn client_engine_version(&self) -> &String { - &self.client_engine_version - } - - /// Get device_name - pub fn device_name(&self) -> &String { - &self.device_name - } - - /// Get device_brand - pub fn device_brand(&self) -> &String { - &self.device_brand - } - - /// Get device_model - pub fn device_model(&self) -> &String { - &self.device_model - } - - /// Get country_code - pub fn country_code(&self) -> &String { - &self.country_code - } - - /// Get country_name - pub fn country_name(&self) -> &String { - &self.country_name - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_creation() { - let _model = ::default(); - let _ = _model.event(); - let _ = _model.user_id(); - let _ = _model.user_email(); - let _ = _model.user_name(); - let _ = _model.mode(); - let _ = _model.user_type(); - let _ = _model.ip(); - let _ = _model.time(); - let _ = _model.os_code(); - let _ = _model.os_name(); - let _ = _model.os_version(); - let _ = _model.client_type(); - let _ = _model.client_code(); - let _ = _model.client_name(); - let _ = _model.client_version(); - let _ = _model.client_engine(); - let _ = _model.client_engine_version(); - let _ = _model.device_name(); - let _ = _model.device_brand(); - let _ = _model.device_model(); - let _ = _model.country_code(); - let _ = _model.country_name(); - } - - #[test] - fn test_log_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/log_list.rs b/src/models/log_list.rs deleted file mode 100644 index 8215ec2..0000000 --- a/src/models/log_list.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! LogList model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Logs List -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct LogList { - /// Total number of logs that matched your query. - #[serde(rename = "total")] - pub total: i64, - /// List of logs. - #[serde(rename = "logs")] - pub logs: Vec, -} - -impl LogList { - /// Get total - pub fn total(&self) -> &i64 { - &self.total - } - - /// Get logs - pub fn logs(&self) -> &Vec { - &self.logs - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_list_creation() { - let _model = ::default(); - let _ = _model.total(); - let _ = _model.logs(); - } - - #[test] - fn test_log_list_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/membership.rs b/src/models/membership.rs index da724ca..bc0954e 100644 --- a/src/models/membership.rs +++ b/src/models/membership.rs @@ -8,59 +8,134 @@ use serde::{Deserialize, Serialize}; pub struct Membership { /// Membership ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Membership creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Membership update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User name. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// User email address. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: String, /// User phone number. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Team name. #[serde(rename = "teamName")] + #[serde(default = "default_team_name")] pub team_name: String, /// Date, the user has been invited to join the team in ISO 8601 format. #[serde(rename = "invited")] + #[serde(default = "default_invited")] pub invited: String, /// Date, the user has accepted the invitation to join the team in ISO 8601 /// format. #[serde(rename = "joined")] + #[serde(default = "default_joined")] pub joined: String, /// User confirmation status, true if the user has joined the team or false /// otherwise. #[serde(rename = "confirm")] + #[serde(default = "default_confirm")] pub confirm: bool, /// Multi factor authentication status, true if the user has MFA enabled or /// false otherwise. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// Most recent access date in ISO 8601 format. Show this attribute by toggling /// membership privacy in the Console. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: String, /// User list of roles #[serde(rename = "roles")] + #[serde(default = "default_roles")] pub roles: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_user_email() -> String { + "".to_string() +} + +fn default_user_phone() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_team_name() -> String { + "".to_string() +} + +fn default_invited() -> String { + "".to_string() +} + +fn default_joined() -> String { + "".to_string() +} + +fn default_confirm() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> String { + "".to_string() +} + +fn default_roles() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Membership { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/membership_list.rs b/src/models/membership_list.rs index 628a569..a5c2d03 100644 --- a/src/models/membership_list.rs +++ b/src/models/membership_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MembershipList { /// Total number of memberships that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of memberships. #[serde(rename = "memberships")] + #[serde(default = "default_memberships")] pub memberships: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_memberships() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MembershipList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/message.rs b/src/models/message.rs index 554149b..29880eb 100644 --- a/src/models/message.rs +++ b/src/models/message.rs @@ -8,24 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Message { /// Message ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Message creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Message update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Message provider type. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// Topic IDs set as recipients. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, /// User IDs set as recipients. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, /// Target IDs set as recipients. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// The scheduled time for message. #[serde(rename = "scheduledAt")] @@ -41,15 +48,58 @@ pub struct Message { pub delivery_errors: Option>, /// Number of recipients the message was delivered to. #[serde(rename = "deliveredTotal")] + #[serde(default = "default_delivered_total")] pub delivered_total: i64, /// Data of the message. #[serde(rename = "data")] + #[serde(default = "default_data")] pub data: serde_json::Value, /// Status of delivery. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::MessageStatus, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_delivered_total() -> i64 { + 0 +} + +fn default_data() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_status() -> crate::enums::MessageStatus { + serde_json::from_value(serde_json::json!("draft")).unwrap() +} + impl Message { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/message_list.rs b/src/models/message_list.rs index de470cb..628ae06 100644 --- a/src/models/message_list.rs +++ b/src/models/message_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MessageList { /// Total number of messages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of messages. #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_messages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MessageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mfa_challenge.rs b/src/models/mfa_challenge.rs index cee280b..ce8a91a 100644 --- a/src/models/mfa_challenge.rs +++ b/src/models/mfa_challenge.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallenge { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl MfaChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_challenge_secret.rs b/src/models/mfa_challenge_secret.rs index 42a9c6e..e21b3ae 100644 --- a/src/models/mfa_challenge_secret.rs +++ b/src/models/mfa_challenge_secret.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallengeSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Challenge code to be delivered to the end user through a custom channel. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl MfaChallengeSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_factors.rs b/src/models/mfa_factors.rs index 14b1ebf..6415f45 100644 --- a/src/models/mfa_factors.rs +++ b/src/models/mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaFactors { /// Can TOTP be used for MFA challenge for this account. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Can phone (SMS) be used for MFA challenge for this account. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Can email be used for MFA challenge for this account. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Can recovery code be used for MFA challenge for this account. #[serde(rename = "recoveryCode")] + #[serde(default = "default_recovery_code")] pub recovery_code: bool, /// Can custom factor be used for MFA challenge for this account. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_totp() -> bool { + false +} + +fn default_phone() -> bool { + false +} + +fn default_email() -> bool { + false +} + +fn default_recovery_code() -> bool { + false +} + +fn default_custom() -> bool { + false +} + impl MfaFactors { /// Get totp pub fn totp(&self) -> &bool { diff --git a/src/models/mfa_recovery_codes.rs b/src/models/mfa_recovery_codes.rs index 44f77a3..c9089ef 100644 --- a/src/models/mfa_recovery_codes.rs +++ b/src/models/mfa_recovery_codes.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct MfaRecoveryCodes { /// Recovery codes. #[serde(rename = "recoveryCodes")] + #[serde(default = "default_recovery_codes")] pub recovery_codes: Vec, } +fn default_recovery_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MfaRecoveryCodes { /// Get recovery_codes pub fn recovery_codes(&self) -> &Vec { diff --git a/src/models/mfa_type.rs b/src/models/mfa_type.rs index 7809d95..69e7a79 100644 --- a/src/models/mfa_type.rs +++ b/src/models/mfa_type.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MfaType { /// Secret token used for TOTP factor. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// URI for authenticator apps. #[serde(rename = "uri")] + #[serde(default = "default_uri")] pub uri: String, } +fn default_secret() -> String { + "".to_string() +} + +fn default_uri() -> String { + "".to_string() +} + impl MfaType { /// Get secret pub fn secret(&self) -> &String { diff --git a/src/models/mock_number.rs b/src/models/mock_number.rs index 1d8ea85..0a7244c 100644 --- a/src/models/mock_number.rs +++ b/src/models/mock_number.rs @@ -9,18 +9,38 @@ pub struct MockNumber { /// Mock phone number for testing phone authentication. Useful for testing /// phone authentication without sending an SMS. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: String, /// Mock OTP for the number. #[serde(rename = "otp")] + #[serde(default = "default_otp")] pub otp: String, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_number() -> String { + "".to_string() +} + +fn default_otp() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl MockNumber { /// Get number pub fn number(&self) -> &String { diff --git a/src/models/mock_number_list.rs b/src/models/mock_number_list.rs index b4d7f7f..44de93f 100644 --- a/src/models/mock_number_list.rs +++ b/src/models/mock_number_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MockNumberList { /// Total number of mockNumbers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of mockNumbers. #[serde(rename = "mockNumbers")] + #[serde(default = "default_mock_numbers")] pub mock_numbers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_mock_numbers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MockNumberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mod.rs b/src/models/mod.rs index 8c4e935..1eb0426 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -22,8 +22,6 @@ pub mod session_list; pub use session_list::SessionList; pub mod identity_list; pub use identity_list::IdentityList; -pub mod log_list; -pub use log_list::LogList; pub mod file_list; pub use file_list::FileList; pub mod bucket_list; @@ -196,8 +194,6 @@ pub mod document; pub use document::Document; pub mod presence; pub use presence::Presence; -pub mod log; -pub use log::Log; pub mod user; pub use user::User; pub mod algo_md5; @@ -268,8 +264,6 @@ pub mod key; pub use key::Key; pub mod ephemeral_key; pub use ephemeral_key::EphemeralKey; -pub mod dev_key; -pub use dev_key::DevKey; pub mod mock_number; pub use mock_number::MockNumber; pub mod o_auth2_github; @@ -396,6 +390,14 @@ pub mod policy_mfa_factors; pub use policy_mfa_factors::PolicyMfaFactors; pub mod policy_passkey; pub use policy_passkey::PolicyPasskey; +pub mod policy_deny_aliased_email; +pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; +pub mod policy_deny_disposable_email; +pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; +pub mod policy_deny_free_email; +pub use policy_deny_free_email::PolicyDenyFreeEmail; +pub mod policy_deny_corporate_email; +pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod platform_web; pub use platform_web::PlatformWeb; pub mod platform_apple; @@ -534,14 +536,6 @@ pub mod dedicated_database_pitr_windows; pub use dedicated_database_pitr_windows::DedicatedDatabasePITRWindows; pub mod backup_policy; pub use backup_policy::BackupPolicy; -pub mod policy_deny_aliased_email; -pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; -pub mod policy_deny_disposable_email; -pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; -pub mod policy_deny_free_email; -pub use policy_deny_free_email::PolicyDenyFreeEmail; -pub mod policy_deny_corporate_email; -pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod dedicated_database_pooler; pub use dedicated_database_pooler::DedicatedDatabasePooler; pub mod postgres_extension; @@ -556,8 +550,6 @@ pub mod dedicated_database_specification; pub use dedicated_database_specification::DedicatedDatabaseSpecification; pub mod dedicated_database_specification_list; pub use dedicated_database_specification_list::DedicatedDatabaseSpecificationList; -pub mod dedicated_database_specification_pricing; -pub use dedicated_database_specification_pricing::DedicatedDatabaseSpecificationPricing; pub mod database_status_connections; pub use database_status_connections::DatabaseStatusConnections; pub mod database_status_replica; @@ -669,7 +661,6 @@ impl Model for ColumnIndexList {} impl Model for UserList {} impl Model for SessionList {} impl Model for IdentityList {} -impl Model for LogList {} impl Model for FileList {} impl Model for BucketList {} impl Model for ResourceTokenList {} @@ -756,7 +747,6 @@ impl Model for ColumnIndex {} impl Model for Row {} impl Model for Document {} impl Model for Presence {} -impl Model for Log {} impl Model for User {} impl Model for AlgoMd5 {} impl Model for AlgoSha {} @@ -792,7 +782,6 @@ impl Model for ProjectProtocol {} impl Model for Webhook {} impl Model for Key {} impl Model for EphemeralKey {} -impl Model for DevKey {} impl Model for MockNumber {} impl Model for OAuth2Github {} impl Model for OAuth2Discord {} @@ -856,6 +845,10 @@ impl Model for PolicyUserLimit {} impl Model for PolicyMembershipPrivacy {} impl Model for PolicyMfaFactors {} impl Model for PolicyPasskey {} +impl Model for PolicyDenyAliasedEmail {} +impl Model for PolicyDenyDisposableEmail {} +impl Model for PolicyDenyFreeEmail {} +impl Model for PolicyDenyCorporateEmail {} impl Model for PlatformWeb {} impl Model for PlatformApple {} impl Model for PlatformAndroid {} @@ -925,10 +918,6 @@ impl Model for ProxyInvalidation {} impl Model for Organization {} impl Model for DedicatedDatabasePITRWindows {} impl Model for BackupPolicy {} -impl Model for PolicyDenyAliasedEmail {} -impl Model for PolicyDenyDisposableEmail {} -impl Model for PolicyDenyFreeEmail {} -impl Model for PolicyDenyCorporateEmail {} impl Model for DedicatedDatabasePooler {} impl Model for PostgresExtension {} impl Model for Program {} @@ -936,7 +925,6 @@ impl Model for BackupRestoration {} impl Model for DedicatedDatabaseRestorationList {} impl Model for DedicatedDatabaseSpecification {} impl Model for DedicatedDatabaseSpecificationList {} -impl Model for DedicatedDatabaseSpecificationPricing {} impl Model for DatabaseStatusConnections {} impl Model for DatabaseStatusReplica {} impl Model for DatabaseStatusVolume {} diff --git a/src/models/o_auth2_amazon.rs b/src/models/o_auth2_amazon.rs index c2359b9..6e79642 100644 --- a/src/models/o_auth2_amazon.rs +++ b/src/models/o_auth2_amazon.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Amazon { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Amazon OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Amazon OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Amazon { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_apple.rs b/src/models/o_auth2_apple.rs index 5022915..3b357f7 100644 --- a/src/models/o_auth2_apple.rs +++ b/src/models/o_auth2_apple.rs @@ -8,34 +8,72 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Apple { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Apple OAuth2 service ID. #[serde(rename = "serviceId")] + #[serde(default = "default_service_id")] pub service_id: String, /// Apple OAuth2 key ID. #[serde(rename = "keyId")] + #[serde(default = "default_key_id")] pub key_id: String, /// Apple OAuth2 team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Apple OAuth2 .p8 private key file contents. The secret key wrapped by the /// PEM markers is 200 characters long. #[serde(rename = "p8File")] + #[serde(default = "default_p8_file")] pub p8_file: String, /// Native Sign in with Apple is active and can be used to create sessions from /// an ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// App bundle IDs accepted as ID token audiences for native Sign in with /// Apple, next to the Services ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_service_id() -> String { + "".to_string() +} + +fn default_key_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_p8_file() -> String { + "".to_string() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Apple { @@ -69,26 +107,14 @@ impl OAuth2Apple { &self.p8_file } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -105,6 +131,8 @@ mod tests { let _ = _model.key_id(); let _ = _model.team_id(); let _ = _model.p8_file(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_appwrite.rs b/src/models/o_auth2_appwrite.rs index 4ca0449..54ce0c8 100644 --- a/src/models/o_auth2_appwrite.rs +++ b/src/models/o_auth2_appwrite.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Appwrite { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Appwrite OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Appwrite OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Appwrite { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_auth0.rs b/src/models/o_auth2_auth0.rs index 12a3426..c974616 100644 --- a/src/models/o_auth2_auth0.rs +++ b/src/models/o_auth2_auth0.rs @@ -8,25 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Auth0 { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Auth0 OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Auth0 OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Auth0 OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Auth0 OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Auth0 { /// Get id pub fn id(&self) -> &String { @@ -48,15 +77,9 @@ impl OAuth2Auth0 { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get endpoint @@ -76,6 +99,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.endpoint(); } diff --git a/src/models/o_auth2_authentik.rs b/src/models/o_auth2_authentik.rs index da60963..8a4735b 100644 --- a/src/models/o_auth2_authentik.rs +++ b/src/models/o_auth2_authentik.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Authentik { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Authentik OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Authentik OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Authentik OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Authentik { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_autodesk.rs b/src/models/o_auth2_autodesk.rs index a487d8a..2f30585 100644 --- a/src/models/o_auth2_autodesk.rs +++ b/src/models/o_auth2_autodesk.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Autodesk { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Autodesk OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Autodesk OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Autodesk { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitbucket.rs b/src/models/o_auth2_bitbucket.rs index cfe595b..1694254 100644 --- a/src/models/o_auth2_bitbucket.rs +++ b/src/models/o_auth2_bitbucket.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitbucket { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitbucket OAuth2 key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Bitbucket OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + impl OAuth2Bitbucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitly.rs b/src/models/o_auth2_bitly.rs index 15a0774..1f0d383 100644 --- a/src/models/o_auth2_bitly.rs +++ b/src/models/o_auth2_bitly.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitly { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitly OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Bitly OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Bitly { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_box.rs b/src/models/o_auth2_box.rs index 83959c8..c2fefe6 100644 --- a/src/models/o_auth2_box.rs +++ b/src/models/o_auth2_box.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Box { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Box OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Box OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Box { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_cloudflare.rs b/src/models/o_auth2_cloudflare.rs index 3f6703f..6c977c2 100644 --- a/src/models/o_auth2_cloudflare.rs +++ b/src/models/o_auth2_cloudflare.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Cloudflare { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Cloudflare OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Cloudflare OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Cloudflare { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dailymotion.rs b/src/models/o_auth2_dailymotion.rs index b94e6bc..795a455 100644 --- a/src/models/o_auth2_dailymotion.rs +++ b/src/models/o_auth2_dailymotion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dailymotion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dailymotion OAuth2 API key. #[serde(rename = "apiKey")] + #[serde(default = "default_api_key")] pub api_key: String, /// Dailymotion OAuth2 API secret. #[serde(rename = "apiSecret")] + #[serde(default = "default_api_secret")] pub api_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_api_key() -> String { + "".to_string() +} + +fn default_api_secret() -> String { + "".to_string() +} + impl OAuth2Dailymotion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_discord.rs b/src/models/o_auth2_discord.rs index 91a601b..9c0c58d 100644 --- a/src/models/o_auth2_discord.rs +++ b/src/models/o_auth2_discord.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Discord { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Discord OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Discord OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Discord OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Discord { @@ -45,15 +69,9 @@ impl OAuth2Discord { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_disqus.rs b/src/models/o_auth2_disqus.rs index 467e840..957c4f6 100644 --- a/src/models/o_auth2_disqus.rs +++ b/src/models/o_auth2_disqus.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Disqus { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Disqus OAuth2 public key. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: String, /// Disqus OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_public_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Disqus { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dropbox.rs b/src/models/o_auth2_dropbox.rs index d566903..9160dbd 100644 --- a/src/models/o_auth2_dropbox.rs +++ b/src/models/o_auth2_dropbox.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dropbox { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dropbox OAuth2 app key. #[serde(rename = "appKey")] + #[serde(default = "default_app_key")] pub app_key: String, /// Dropbox OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_key() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Dropbox { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_etsy.rs b/src/models/o_auth2_etsy.rs index cf6bab9..a0158a0 100644 --- a/src/models/o_auth2_etsy.rs +++ b/src/models/o_auth2_etsy.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Etsy { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Etsy OAuth2 keystring. #[serde(rename = "keyString")] + #[serde(default = "default_key_string")] pub key_string: String, /// Etsy OAuth2 shared secret. #[serde(rename = "sharedSecret")] + #[serde(default = "default_shared_secret")] pub shared_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key_string() -> String { + "".to_string() +} + +fn default_shared_secret() -> String { + "".to_string() +} + impl OAuth2Etsy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_facebook.rs b/src/models/o_auth2_facebook.rs index c8c3bd9..7cabbef 100644 --- a/src/models/o_auth2_facebook.rs +++ b/src/models/o_auth2_facebook.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Facebook { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Facebook OAuth2 app ID. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Facebook OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Facebook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_figma.rs b/src/models/o_auth2_figma.rs index 0ef3e3b..99c241c 100644 --- a/src/models/o_auth2_figma.rs +++ b/src/models/o_auth2_figma.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Figma { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Figma OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Figma OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Figma { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_fusion_auth.rs b/src/models/o_auth2_fusion_auth.rs index 2222752..a9a7122 100644 --- a/src/models/o_auth2_fusion_auth.rs +++ b/src/models/o_auth2_fusion_auth.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2FusionAuth { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// FusionAuth OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// FusionAuth OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// FusionAuth OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2FusionAuth { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_github.rs b/src/models/o_auth2_github.rs index 1be7953..684abde 100644 --- a/src/models/o_auth2_github.rs +++ b/src/models/o_auth2_github.rs @@ -8,21 +8,45 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Github { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App /// ID and client ID are available. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// GitHub OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// GitHub OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Github { @@ -46,15 +70,9 @@ impl OAuth2Github { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -69,6 +87,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_gitlab.rs b/src/models/o_auth2_gitlab.rs index 8444d1b..fa76ce7 100644 --- a/src/models/o_auth2_gitlab.rs +++ b/src/models/o_auth2_gitlab.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Gitlab { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitLab OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// GitLab OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted /// instances. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Gitlab { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_google.rs b/src/models/o_auth2_google.rs index ece34e2..e9261a9 100644 --- a/src/models/o_auth2_google.rs +++ b/src/models/o_auth2_google.rs @@ -8,30 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Google { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Google OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Google OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Google OAuth2 prompt values. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: Vec, /// Native Google sign-in is active and can be used to create sessions from an /// ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// Additional OAuth2 client IDs accepted as ID token audiences for native /// sign-in, next to the client ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!(["consent"])).unwrap() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Google { @@ -60,26 +93,14 @@ impl OAuth2Google { &self.prompt } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -95,6 +116,8 @@ mod tests { let _ = _model.client_id(); let _ = _model.client_secret(); let _ = _model.prompt(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_hugging_face.rs b/src/models/o_auth2_hugging_face.rs index 6259543..43b9831 100644 --- a/src/models/o_auth2_hugging_face.rs +++ b/src/models/o_auth2_hugging_face.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2HuggingFace { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Hugging Face OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Hugging Face OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2HuggingFace { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_keycloak.rs b/src/models/o_auth2_keycloak.rs index 1586924..b5fd439 100644 --- a/src/models/o_auth2_keycloak.rs +++ b/src/models/o_auth2_keycloak.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Keycloak { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Keycloak OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Keycloak OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Keycloak OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, /// Keycloak OAuth2 realm name. #[serde(rename = "realmName")] + #[serde(default = "default_realm_name")] pub realm_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + +fn default_realm_name() -> String { + "".to_string() +} + impl OAuth2Keycloak { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_kick.rs b/src/models/o_auth2_kick.rs index d3f982f..12376b0 100644 --- a/src/models/o_auth2_kick.rs +++ b/src/models/o_auth2_kick.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Kick { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Kick OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Kick OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Kick { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_linkedin.rs b/src/models/o_auth2_linkedin.rs index 1c1077e..e76011f 100644 --- a/src/models/o_auth2_linkedin.rs +++ b/src/models/o_auth2_linkedin.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Linkedin { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// LinkedIn OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// LinkedIn OAuth2 primary client secret. #[serde(rename = "primaryClientSecret")] + #[serde(default = "default_primary_client_secret")] pub primary_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_primary_client_secret() -> String { + "".to_string() +} + impl OAuth2Linkedin { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_microsoft.rs b/src/models/o_auth2_microsoft.rs index 3a2535b..3aab893 100644 --- a/src/models/o_auth2_microsoft.rs +++ b/src/models/o_auth2_microsoft.rs @@ -8,26 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Microsoft { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Microsoft OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// Microsoft OAuth2 application secret. #[serde(rename = "applicationSecret")] + #[serde(default = "default_application_secret")] pub application_secret: String, /// Microsoft OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Microsoft Entra ID tenant identifier. Use 'common', 'organizations', /// 'consumers' or a specific tenant ID. #[serde(rename = "tenant")] + #[serde(default = "default_tenant")] pub tenant: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_application_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tenant() -> String { + "".to_string() +} + impl OAuth2Microsoft { /// Get id pub fn id(&self) -> &String { @@ -49,15 +78,9 @@ impl OAuth2Microsoft { &self.application_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get tenant @@ -77,6 +100,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.application_id(); let _ = _model.application_secret(); + let _ = _model.prompt(); let _ = _model.tenant(); } diff --git a/src/models/o_auth2_notion.rs b/src/models/o_auth2_notion.rs index c42807b..bb32958 100644 --- a/src/models/o_auth2_notion.rs +++ b/src/models/o_auth2_notion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Notion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Notion OAuth2 client ID. #[serde(rename = "oauthClientId")] + #[serde(default = "default_oauth_client_id")] pub oauth_client_id: String, /// Notion OAuth2 client secret. #[serde(rename = "oauthClientSecret")] + #[serde(default = "default_oauth_client_secret")] pub oauth_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth_client_id() -> String { + "".to_string() +} + +fn default_oauth_client_secret() -> String { + "".to_string() +} + impl OAuth2Notion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_oidc.rs b/src/models/o_auth2_oidc.rs index 010281d..aa2df42 100644 --- a/src/models/o_auth2_oidc.rs +++ b/src/models/o_auth2_oidc.rs @@ -8,33 +8,42 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Oidc { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OpenID Connect OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// OpenID Connect OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, + /// OpenID Connect prompt values controlling the authentication and consent + /// screens. + #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] + pub prompt: Vec, /// OpenID Connect well-known configuration URL. When set, authorization, /// token, and user info endpoints can be discovered automatically. #[serde(rename = "wellKnownURL")] + #[serde(default = "default_well_known_url")] pub well_known_url: String, /// OpenID Connect authorization endpoint URL. #[serde(rename = "authorizationURL")] + #[serde(default = "default_authorization_url")] pub authorization_url: String, /// OpenID Connect token endpoint URL. #[serde(rename = "tokenURL")] + #[serde(default = "default_token_url")] pub token_url: String, /// OpenID Connect user info endpoint URL. #[serde(rename = "userInfoURL")] + #[serde(default = "default_user_info_url")] pub user_info_url: String, - /// OpenID Connect prompt values controlling the authentication and consent - /// screens. - #[serde(rename = "prompt")] - pub prompt: Vec, /// Maximum authentication age in seconds. When set, the user must have /// authenticated within this many seconds. #[serde(rename = "maxAge")] @@ -42,6 +51,42 @@ pub struct OAuth2Oidc { pub max_age: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_well_known_url() -> String { + "".to_string() +} + +fn default_authorization_url() -> String { + "".to_string() +} + +fn default_token_url() -> String { + "".to_string() +} + +fn default_user_info_url() -> String { + "".to_string() +} + impl OAuth2Oidc { /// Get id pub fn id(&self) -> &String { @@ -63,6 +108,11 @@ impl OAuth2Oidc { &self.client_secret } + /// Get prompt + pub fn prompt(&self) -> &Vec { + &self.prompt + } + /// Get well_known_url pub fn well_known_url(&self) -> &String { &self.well_known_url @@ -83,11 +133,6 @@ impl OAuth2Oidc { &self.user_info_url } - /// Get prompt - pub fn prompt(&self) -> &Vec { - &self.prompt - } - /// Set max_age pub fn set_max_age(mut self, max_age: i64) -> Self { self.max_age = Some(max_age); @@ -111,11 +156,11 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.well_known_url(); let _ = _model.authorization_url(); let _ = _model.token_url(); let _ = _model.user_info_url(); - let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_okta.rs b/src/models/o_auth2_okta.rs index e8fdf00..be8da90 100644 --- a/src/models/o_auth2_okta.rs +++ b/src/models/o_auth2_okta.rs @@ -8,28 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Okta { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Okta OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Okta OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Okta OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Okta OAuth2 domain. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Okta OAuth2 authorization server ID. #[serde(rename = "authorizationServerId")] + #[serde(default = "default_authorization_server_id")] pub authorization_server_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_authorization_server_id() -> String { + "".to_string() +} + impl OAuth2Okta { /// Get id pub fn id(&self) -> &String { @@ -51,15 +85,9 @@ impl OAuth2Okta { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get domain @@ -84,6 +112,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.domain(); let _ = _model.authorization_server_id(); } diff --git a/src/models/o_auth2_paypal.rs b/src/models/o_auth2_paypal.rs index 41539e5..50ff622 100644 --- a/src/models/o_auth2_paypal.rs +++ b/src/models/o_auth2_paypal.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Paypal { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// PayPal OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// PayPal OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Paypal { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_podio.rs b/src/models/o_auth2_podio.rs index 87bb74a..cd87360 100644 --- a/src/models/o_auth2_podio.rs +++ b/src/models/o_auth2_podio.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Podio { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Podio OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Podio OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Podio { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_provider_list.rs b/src/models/o_auth2_provider_list.rs index a3354d1..510881c 100644 --- a/src/models/o_auth2_provider_list.rs +++ b/src/models/o_auth2_provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2ProviderList { /// Total number of OAuth2 providers in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of OAuth2 providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl OAuth2ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/o_auth2_resend.rs b/src/models/o_auth2_resend.rs index 1658315..773278e 100644 --- a/src/models/o_auth2_resend.rs +++ b/src/models/o_auth2_resend.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Resend { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Resend OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Resend OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Resend { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_salesforce.rs b/src/models/o_auth2_salesforce.rs index 4565047..addaba3 100644 --- a/src/models/o_auth2_salesforce.rs +++ b/src/models/o_auth2_salesforce.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Salesforce { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Salesforce OAuth2 consumer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// Salesforce OAuth2 consumer secret. #[serde(rename = "customerSecret")] + #[serde(default = "default_customer_secret")] pub customer_secret: String, /// Salesforce OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_customer_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Salesforce { @@ -45,15 +69,9 @@ impl OAuth2Salesforce { &self.customer_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.customer_key(); let _ = _model.customer_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_slack.rs b/src/models/o_auth2_slack.rs index 3045596..1563a50 100644 --- a/src/models/o_auth2_slack.rs +++ b/src/models/o_auth2_slack.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Slack { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Slack OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Slack OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Slack { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_spotify.rs b/src/models/o_auth2_spotify.rs index 00572b9..00d8ad3 100644 --- a/src/models/o_auth2_spotify.rs +++ b/src/models/o_auth2_spotify.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Spotify { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Spotify OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Spotify OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Spotify { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_stripe.rs b/src/models/o_auth2_stripe.rs index 5b1565d..8c7a9c0 100644 --- a/src/models/o_auth2_stripe.rs +++ b/src/models/o_auth2_stripe.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Stripe { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Stripe OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Stripe OAuth2 API secret key. #[serde(rename = "apiSecretKey")] + #[serde(default = "default_api_secret_key")] pub api_secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_api_secret_key() -> String { + "".to_string() +} + impl OAuth2Stripe { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_tradeshift.rs b/src/models/o_auth2_tradeshift.rs index ba79a82..70533ca 100644 --- a/src/models/o_auth2_tradeshift.rs +++ b/src/models/o_auth2_tradeshift.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Tradeshift { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Tradeshift OAuth2 client ID. #[serde(rename = "oauth2ClientId")] + #[serde(default = "default_oauth2_client_id")] pub oauth2_client_id: String, /// Tradeshift OAuth2 client secret. #[serde(rename = "oauth2ClientSecret")] + #[serde(default = "default_oauth2_client_secret")] pub oauth2_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth2_client_id() -> String { + "".to_string() +} + +fn default_oauth2_client_secret() -> String { + "".to_string() +} + impl OAuth2Tradeshift { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_twitch.rs b/src/models/o_auth2_twitch.rs index e0550f7..d3f246a 100644 --- a/src/models/o_auth2_twitch.rs +++ b/src/models/o_auth2_twitch.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Twitch { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Twitch OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Twitch OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Twitch { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_word_press.rs b/src/models/o_auth2_word_press.rs index a340ebc..52fb61b 100644 --- a/src/models/o_auth2_word_press.rs +++ b/src/models/o_auth2_word_press.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2WordPress { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// WordPress OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// WordPress OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2WordPress { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_x.rs b/src/models/o_auth2_x.rs index c3c4f83..8161a8e 100644 --- a/src/models/o_auth2_x.rs +++ b/src/models/o_auth2_x.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2X { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// X OAuth2 customer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// X OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2X { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yahoo.rs b/src/models/o_auth2_yahoo.rs index 18c69b1..d69e55e 100644 --- a/src/models/o_auth2_yahoo.rs +++ b/src/models/o_auth2_yahoo.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yahoo { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yahoo OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yahoo OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yahoo { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yandex.rs b/src/models/o_auth2_yandex.rs index 9db7bc6..d7e59dd 100644 --- a/src/models/o_auth2_yandex.rs +++ b/src/models/o_auth2_yandex.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yandex { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yandex OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yandex OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yandex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_zoho.rs b/src/models/o_auth2_zoho.rs index 58cef47..8477a96 100644 --- a/src/models/o_auth2_zoho.rs +++ b/src/models/o_auth2_zoho.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoho { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoho OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoho OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Zoho OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Zoho { @@ -45,15 +69,9 @@ impl OAuth2Zoho { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_zoom.rs b/src/models/o_auth2_zoom.rs index e0047c3..4c44b8d 100644 --- a/src/models/o_auth2_zoom.rs +++ b/src/models/o_auth2_zoom.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoom { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoom OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoom OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Zoom { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_approve.rs b/src/models/oauth2_approve.rs index a946f11..ac5ce43 100644 --- a/src/models/oauth2_approve.rs +++ b/src/models/oauth2_approve.rs @@ -10,9 +10,14 @@ pub struct Oauth2Approve { /// carrying the authorization `code` and/or `id_token` along with the original /// `state`. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Approve { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_authorize.rs b/src/models/oauth2_authorize.rs index 5063ed7..89f1f92 100644 --- a/src/models/oauth2_authorize.rs +++ b/src/models/oauth2_authorize.rs @@ -10,13 +10,23 @@ pub struct Oauth2Authorize { /// the approve or reject endpoint. Empty when a redirect URL is returned /// instead. #[serde(rename = "grantId")] + #[serde(default = "default_grant_id")] pub grant_id: String, /// URL the end user should be redirected to when the flow can complete without /// consent. Empty when consent is still required. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_grant_id() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Authorize { /// Get grant_id pub fn grant_id(&self) -> &String { diff --git a/src/models/oauth2_consent.rs b/src/models/oauth2_consent.rs index 995d15b..a6e4b9e 100644 --- a/src/models/oauth2_consent.rs +++ b/src/models/oauth2_consent.rs @@ -8,40 +8,90 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Consent { /// Consent ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Consent creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Consent update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the consent belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the consent was given to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the consent was given to. /// Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes the user consented to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators the user consented to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details the user consented to, as a JSON string. Each entry /// has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Consent expiration time in ISO 8601 format. Empty when the consent has no /// token-bound expiry yet. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Consent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_list.rs b/src/models/oauth2_consent_list.rs index 3982df2..b019afe 100644 --- a/src/models/oauth2_consent_list.rs +++ b/src/models/oauth2_consent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentList { /// Total number of consents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of consents. #[serde(rename = "consents")] + #[serde(default = "default_consents")] pub consents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_consents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_consent_token.rs b/src/models/oauth2_consent_token.rs index 4d2f43f..776ba73 100644 --- a/src/models/oauth2_consent_token.rs +++ b/src/models/oauth2_consent_token.rs @@ -8,44 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentToken { /// Token family ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Token update date in ISO 8601 format. Refreshing the token family updates /// this. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the consent the token family was issued under. #[serde(rename = "consentId")] + #[serde(default = "default_consent_id")] pub consent_id: String, /// ID of the user the token family belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the token family was issued to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the token family was issued /// to. Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes granted on the token family. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators granted on the token family. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details granted on the token family, as a JSON string. Each /// entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Expiration time of the current access token of this family in ISO 8601 /// format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_consent_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2ConsentToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_token_list.rs b/src/models/oauth2_consent_token_list.rs index 9f5f5ad..906b8e2 100644 --- a/src/models/oauth2_consent_token_list.rs +++ b/src/models/oauth2_consent_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_device_authorization.rs b/src/models/oauth2_device_authorization.rs index 80feee2..f0bef4d 100644 --- a/src/models/oauth2_device_authorization.rs +++ b/src/models/oauth2_device_authorization.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2DeviceAuthorization { /// Device verification code used by the client to poll the token endpoint. #[serde(rename = "device_code")] + #[serde(default = "default_device_code")] pub device_code: String, /// Short code the end user enters on the verification page. #[serde(rename = "user_code")] + #[serde(default = "default_user_code")] pub user_code: String, /// URL where the end user enters the user code. #[serde(rename = "verification_uri")] + #[serde(default = "default_verification_uri")] pub verification_uri: String, /// Verification URL with the user code prefilled as a query parameter. #[serde(rename = "verification_uri_complete")] + #[serde(default = "default_verification_uri_complete")] pub verification_uri_complete: String, /// Lifetime of the device code and user code in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// Minimum polling interval for the token endpoint in seconds. #[serde(rename = "interval")] + #[serde(default = "default_interval")] pub interval: i64, } +fn default_device_code() -> String { + "".to_string() +} + +fn default_user_code() -> String { + "".to_string() +} + +fn default_verification_uri() -> String { + "".to_string() +} + +fn default_verification_uri_complete() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_interval() -> i64 { + 0 +} + impl Oauth2DeviceAuthorization { /// Get device_code pub fn device_code(&self) -> &String { diff --git a/src/models/oauth2_grant.rs b/src/models/oauth2_grant.rs index 16d716d..b6e37b0 100644 --- a/src/models/oauth2_grant.rs +++ b/src/models/oauth2_grant.rs @@ -8,45 +8,105 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Grant { /// Grant ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Grant creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Grant update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the grant belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the OAuth2 client (app) the grant was requested for. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Requested OAuth2 scopes the user is being asked to consent to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Requested RFC 8707 resource indicators the user is being asked to consent /// to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Requested authorization_details the user is being asked to consent to, as a /// JSON string. Each entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// OIDC prompt directive the consent screen should honor. Space-separated list /// of: login, consent, select_account. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: String, /// Redirect URI the user will be sent to after the flow completes. #[serde(rename = "redirectUri")] + #[serde(default = "default_redirect_uri")] pub redirect_uri: String, /// Unix timestamp of when the user last authenticated. #[serde(rename = "authTime")] + #[serde(default = "default_auth_time")] pub auth_time: i64, /// Grant expiration time in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_prompt() -> String { + "".to_string() +} + +fn default_redirect_uri() -> String { + "".to_string() +} + +fn default_auth_time() -> i64 { + 0 +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Grant { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization.rs b/src/models/oauth2_organization.rs index b2c20fc..ff1bf2b 100644 --- a/src/models/oauth2_organization.rs +++ b/src/models/oauth2_organization.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Organization { /// Organization ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, } +fn default_id() -> String { + "".to_string() +} + impl Oauth2Organization { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization_list.rs b/src/models/oauth2_organization_list.rs index 1309964..0188ebd 100644 --- a/src/models/oauth2_organization_list.rs +++ b/src/models/oauth2_organization_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2OrganizationList { /// Total number of organizations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of organizations. #[serde(rename = "organizations")] + #[serde(default = "default_organizations")] pub organizations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_organizations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2OrganizationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_par.rs b/src/models/oauth2_par.rs index f1d779e..09e366f 100644 --- a/src/models/oauth2_par.rs +++ b/src/models/oauth2_par.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2PAR { /// Authorization request handle to pass to the authorize endpoint. #[serde(rename = "request_uri")] + #[serde(default = "default_request_uri")] pub request_uri: String, /// Lifetime of the authorization request handle in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, } +fn default_request_uri() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + impl Oauth2PAR { /// Get request_uri pub fn request_uri(&self) -> &String { diff --git a/src/models/oauth2_project.rs b/src/models/oauth2_project.rs index 5af4e85..78ea717 100644 --- a/src/models/oauth2_project.rs +++ b/src/models/oauth2_project.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Region ID the project is deployed in. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// API endpoint of the region the project is deployed in. Empty when the /// region has no public hostname configured. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl Oauth2Project { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_project_list.rs b/src/models/oauth2_project_list.rs index 2e849fb..3e8b16c 100644 --- a/src/models/oauth2_project_list.rs +++ b/src/models/oauth2_project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_reject.rs b/src/models/oauth2_reject.rs index 5daab49..7051bb4 100644 --- a/src/models/oauth2_reject.rs +++ b/src/models/oauth2_reject.rs @@ -9,9 +9,14 @@ pub struct Oauth2Reject { /// URL the end user should be redirected to after the grant is rejected, /// carrying an `access_denied` error. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Reject { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_token.rs b/src/models/oauth2_token.rs index 37b8552..9c647fb 100644 --- a/src/models/oauth2_token.rs +++ b/src/models/oauth2_token.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Token { /// OAuth2 access token. #[serde(rename = "access_token")] + #[serde(default = "default_access_token")] pub access_token: String, /// OAuth2 token type. #[serde(rename = "token_type")] + #[serde(default = "default_token_type")] pub token_type: String, /// Access token lifetime in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// OAuth2 refresh token. #[serde(rename = "refresh_token")] + #[serde(default = "default_refresh_token")] pub refresh_token: String, /// Space-separated scopes granted to the access token. #[serde(rename = "scope")] + #[serde(default = "default_scope")] pub scope: String, /// Granted RFC 9396 authorization details as a JSON string. #[serde(rename = "authorization_details")] @@ -31,6 +36,26 @@ pub struct Oauth2Token { pub id_token: Option, } +fn default_access_token() -> String { + "".to_string() +} + +fn default_token_type() -> String { + "Bearer".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_refresh_token() -> String { + "".to_string() +} + +fn default_scope() -> String { + "".to_string() +} + impl Oauth2Token { /// Get access_token pub fn access_token(&self) -> &String { diff --git a/src/models/organization.rs b/src/models/organization.rs index f7ec61d..82eeded 100644 --- a/src/models/organization.rs +++ b/src/models/organization.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Organization { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] @@ -30,44 +35,55 @@ pub struct Organization { pub billing_budget: Option, /// Project budget limit #[serde(rename = "budgetAlerts")] + #[serde(default = "default_budget_alerts")] pub budget_alerts: Vec, /// Organization's billing plan ID. #[serde(rename = "billingPlan")] + #[serde(default = "default_billing_plan")] pub billing_plan: String, /// Organization's billing plan ID. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, /// Organization's billing plan. #[serde(rename = "billingPlanDetails")] pub billing_plan_details: crate::models::BillingPlan, /// Billing email set for the organization. #[serde(rename = "billingEmail")] + #[serde(default = "default_billing_email")] pub billing_email: String, /// Billing cycle start date. #[serde(rename = "billingStartDate")] - pub billing_start_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_start_date: Option, /// Current invoice cycle start date. #[serde(rename = "billingCurrentInvoiceDate")] - pub billing_current_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_current_invoice_date: Option, /// Next invoice cycle start date. #[serde(rename = "billingNextInvoiceDate")] - pub billing_next_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_next_invoice_date: Option, /// Start date of trial. #[serde(rename = "billingTrialStartDate")] #[serde(skip_serializing_if = "Option::is_none")] pub billing_trial_start_date: Option, /// Number of trial days. #[serde(rename = "billingTrialDays")] - pub billing_trial_days: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_trial_days: Option, /// Current active aggregation id. #[serde(rename = "billingAggregationId")] - pub billing_aggregation_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_aggregation_id: Option, /// Current active aggregation id. #[serde(rename = "billingInvoiceId")] - pub billing_invoice_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_invoice_id: Option, /// Default payment method. #[serde(rename = "paymentMethodId")] - pub payment_method_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_id: Option, /// Default payment method. #[serde(rename = "billingAddressId")] #[serde(skip_serializing_if = "Option::is_none")] @@ -78,6 +94,7 @@ pub struct Organization { pub backup_payment_method_id: Option, /// Team status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Remarks on team status. #[serde(rename = "remarks")] @@ -117,15 +134,70 @@ pub struct Organization { pub billing_tax_id: Option, /// Marked for deletion #[serde(rename = "markedForDeletion")] + #[serde(default = "default_marked_for_deletion")] pub marked_for_deletion: bool, /// Product with which the organization is associated (appwrite or imagine) #[serde(rename = "platform")] + #[serde(default = "default_platform")] pub platform: String, /// Selected projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + +fn default_budget_alerts() -> Vec { + serde_json::from_value(serde_json::json!([75])).unwrap() +} + +fn default_billing_plan() -> String { + "tier-0".to_string() +} + +fn default_billing_plan_id() -> String { + "tier-0".to_string() +} + +fn default_billing_email() -> String { + "".to_string() +} + +fn default_status() -> String { + "draft".to_string() +} + +fn default_marked_for_deletion() -> bool { + false +} + +fn default_platform() -> String { + "appwrite".to_string() +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Organization { /// Get id pub fn id(&self) -> &String { @@ -193,19 +265,40 @@ impl Organization { &self.billing_email } + /// Set billing_start_date + pub fn set_billing_start_date(mut self, billing_start_date: String) -> Self { + self.billing_start_date = Some(billing_start_date); + self + } + /// Get billing_start_date - pub fn billing_start_date(&self) -> &String { - &self.billing_start_date + pub fn billing_start_date(&self) -> Option<&String> { + self.billing_start_date.as_ref() + } + + /// Set billing_current_invoice_date + pub fn set_billing_current_invoice_date( + mut self, + billing_current_invoice_date: String, + ) -> Self { + self.billing_current_invoice_date = Some(billing_current_invoice_date); + self } /// Get billing_current_invoice_date - pub fn billing_current_invoice_date(&self) -> &String { - &self.billing_current_invoice_date + pub fn billing_current_invoice_date(&self) -> Option<&String> { + self.billing_current_invoice_date.as_ref() + } + + /// Set billing_next_invoice_date + pub fn set_billing_next_invoice_date(mut self, billing_next_invoice_date: String) -> Self { + self.billing_next_invoice_date = Some(billing_next_invoice_date); + self } /// Get billing_next_invoice_date - pub fn billing_next_invoice_date(&self) -> &String { - &self.billing_next_invoice_date + pub fn billing_next_invoice_date(&self) -> Option<&String> { + self.billing_next_invoice_date.as_ref() } /// Set billing_trial_start_date @@ -219,24 +312,48 @@ impl Organization { self.billing_trial_start_date.as_ref() } + /// Set billing_trial_days + pub fn set_billing_trial_days(mut self, billing_trial_days: i64) -> Self { + self.billing_trial_days = Some(billing_trial_days); + self + } + /// Get billing_trial_days - pub fn billing_trial_days(&self) -> &i64 { - &self.billing_trial_days + pub fn billing_trial_days(&self) -> Option<&i64> { + self.billing_trial_days.as_ref() + } + + /// Set billing_aggregation_id + pub fn set_billing_aggregation_id(mut self, billing_aggregation_id: String) -> Self { + self.billing_aggregation_id = Some(billing_aggregation_id); + self } /// Get billing_aggregation_id - pub fn billing_aggregation_id(&self) -> &String { - &self.billing_aggregation_id + pub fn billing_aggregation_id(&self) -> Option<&String> { + self.billing_aggregation_id.as_ref() + } + + /// Set billing_invoice_id + pub fn set_billing_invoice_id(mut self, billing_invoice_id: String) -> Self { + self.billing_invoice_id = Some(billing_invoice_id); + self } /// Get billing_invoice_id - pub fn billing_invoice_id(&self) -> &String { - &self.billing_invoice_id + pub fn billing_invoice_id(&self) -> Option<&String> { + self.billing_invoice_id.as_ref() + } + + /// Set payment_method_id + pub fn set_payment_method_id(mut self, payment_method_id: String) -> Self { + self.payment_method_id = Some(payment_method_id); + self } /// Get payment_method_id - pub fn payment_method_id(&self) -> &String { - &self.payment_method_id + pub fn payment_method_id(&self) -> Option<&String> { + self.payment_method_id.as_ref() } /// Set billing_address_id @@ -402,13 +519,6 @@ mod tests { let _ = _model.billing_plan_id(); let _ = _model.billing_plan_details(); let _ = _model.billing_email(); - let _ = _model.billing_start_date(); - let _ = _model.billing_current_invoice_date(); - let _ = _model.billing_next_invoice_date(); - let _ = _model.billing_trial_days(); - let _ = _model.billing_aggregation_id(); - let _ = _model.billing_invoice_id(); - let _ = _model.payment_method_id(); let _ = _model.status(); let _ = _model.marked_for_deletion(); let _ = _model.platform(); diff --git a/src/models/passkey.rs b/src/models/passkey.rs index 0685af4..9f9afb4 100644 --- a/src/models/passkey.rs +++ b/src/models/passkey.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct Passkey { /// Passkey ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Passkey creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Passkey update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Passkey name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Most recent sign-in with this passkey in ISO 8601 format. Empty until the /// passkey is used to sign in. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl Passkey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_challenge.rs b/src/models/passkey_challenge.rs index 8ecada5..a0cffe5 100644 --- a/src/models/passkey_challenge.rs +++ b/src/models/passkey_challenge.rs @@ -9,23 +9,48 @@ pub struct PasskeyChallenge { /// Challenge ID. When signing in, pass it back with the credential to receive /// a token. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Challenge creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// ID of the passkey being registered. Empty for sign-in challenges. #[serde(rename = "passkeyId")] + #[serde(default = "default_passkey_id")] pub passkey_id: String, /// Challenge expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// WebAuthn options in JSON form. Pass them to /// `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or /// `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: serde_json::Value, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_passkey_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_public_key() -> serde_json::Value { + serde_json::json!({}) +} + impl PasskeyChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_list.rs b/src/models/passkey_list.rs index 8b9e05e..5f9a82c 100644 --- a/src/models/passkey_list.rs +++ b/src/models/passkey_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PasskeyList { /// Total number of passkeys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of passkeys. #[serde(rename = "passkeys")] + #[serde(default = "default_passkeys")] pub passkeys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_passkeys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PasskeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/phone.rs b/src/models/phone.rs index 2d6a27c..f06631b 100644 --- a/src/models/phone.rs +++ b/src/models/phone.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Phone { /// Phone code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + impl Phone { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/phone_list.rs b/src/models/phone_list.rs index 53939ae..b17138c 100644 --- a/src/models/phone_list.rs +++ b/src/models/phone_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PhoneList { /// Total number of phones that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of phones. #[serde(rename = "phones")] + #[serde(default = "default_phones")] pub phones: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_phones() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PhoneList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_android.rs b/src/models/platform_android.rs index 7f35a47..28a4ac1 100644 --- a/src/models/platform_android.rs +++ b/src/models/platform_android.rs @@ -8,27 +8,56 @@ use serde::{Deserialize, Serialize}; pub struct PlatformAndroid { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Android application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// SHA-256 fingerprints of the certificates the app is signed with. Passkeys /// created in the app are accepted when its signature matches one. #[serde(rename = "fingerprints")] - #[serde(skip_serializing_if = "Option::is_none")] - pub fingerprints: Option>, + #[serde(default = "default_fingerprints")] + pub fingerprints: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_fingerprints() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl PlatformAndroid { @@ -62,15 +91,9 @@ impl PlatformAndroid { &self.application_id } - /// Set fingerprints - pub fn set_fingerprints(mut self, fingerprints: Vec) -> Self { - self.fingerprints = Some(fingerprints); - self - } - /// Get fingerprints - pub fn fingerprints(&self) -> Option<&Vec> { - self.fingerprints.as_ref() + pub fn fingerprints(&self) -> &Vec { + &self.fingerprints } } @@ -87,6 +110,7 @@ mod tests { let _ = _model.name(); let _ = _model.r#type(); let _ = _model.application_id(); + let _ = _model.fingerprints(); } #[test] diff --git a/src/models/platform_apple.rs b/src/models/platform_apple.rs index c157274..fd57555 100644 --- a/src/models/platform_apple.rs +++ b/src/models/platform_apple.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformApple { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Apple bundle identifier. #[serde(rename = "bundleIdentifier")] + #[serde(default = "default_bundle_identifier")] pub bundle_identifier: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_bundle_identifier() -> String { + "".to_string() +} + impl PlatformApple { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_linux.rs b/src/models/platform_linux.rs index d305b51..db7b998 100644 --- a/src/models/platform_linux.rs +++ b/src/models/platform_linux.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformLinux { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Linux package name. #[serde(rename = "packageName")] + #[serde(default = "default_package_name")] pub package_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_name() -> String { + "".to_string() +} + impl PlatformLinux { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_list.rs b/src/models/platform_list.rs index 523fc50..5caaee7 100644 --- a/src/models/platform_list.rs +++ b/src/models/platform_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PlatformList { /// Total number of platforms in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of platforms. #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_platforms() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PlatformList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_web.rs b/src/models/platform_web.rs index 5daea92..a35b4c5 100644 --- a/src/models/platform_web.rs +++ b/src/models/platform_web.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWeb { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Web app hostname. Empty string for other platforms. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + impl PlatformWeb { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_windows.rs b/src/models/platform_windows.rs index da5c08f..52d9c7a 100644 --- a/src/models/platform_windows.rs +++ b/src/models/platform_windows.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWindows { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Windows package identifier name. #[serde(rename = "packageIdentifierName")] + #[serde(default = "default_package_identifier_name")] pub package_identifier_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_identifier_name() -> String { + "".to_string() +} + impl PlatformWindows { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_aliased_email.rs b/src/models/policy_deny_aliased_email.rs index c7327b0..bca4bde 100644 --- a/src/models/policy_deny_aliased_email.rs +++ b/src/models/policy_deny_aliased_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyAliasedEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny aliased email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyAliasedEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_corporate_email.rs b/src/models/policy_deny_corporate_email.rs index 8b271b9..b90e444 100644 --- a/src/models/policy_deny_corporate_email.rs +++ b/src/models/policy_deny_corporate_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyCorporateEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny non-corporate email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyCorporateEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_disposable_email.rs b/src/models/policy_deny_disposable_email.rs index 029a4fe..3cfb4ec 100644 --- a/src/models/policy_deny_disposable_email.rs +++ b/src/models/policy_deny_disposable_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyDisposableEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny disposable email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyDisposableEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_free_email.rs b/src/models/policy_deny_free_email.rs index 6038f66..5c1b61d 100644 --- a/src/models/policy_deny_free_email.rs +++ b/src/models/policy_deny_free_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyFreeEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny free email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyFreeEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_list.rs b/src/models/policy_list.rs index 559b319..cec5f0b 100644 --- a/src/models/policy_list.rs +++ b/src/models/policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyList { /// Total number of policies in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/policy_membership_privacy.rs b/src/models/policy_membership_privacy.rs index 8b17314..c42cc90 100644 --- a/src/models/policy_membership_privacy.rs +++ b/src/models/policy_membership_privacy.rs @@ -8,27 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMembershipPrivacy { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether user ID is visible in memberships. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: bool, /// Whether user email is visible in memberships. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: bool, /// Whether user phone is visible in memberships. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: bool, /// Whether user name is visible in memberships. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: bool, /// Whether user MFA status is visible in memberships. #[serde(rename = "userMFA")] + #[serde(default = "default_user_mfa")] pub user_mfa: bool, /// Whether user last access time is visible in memberships. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_user_id() -> bool { + false +} + +fn default_user_email() -> bool { + false +} + +fn default_user_phone() -> bool { + false +} + +fn default_user_name() -> bool { + false +} + +fn default_user_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> bool { + false +} + impl PolicyMembershipPrivacy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_mfa_factors.rs b/src/models/policy_mfa_factors.rs index a6634b6..5d6a1f3 100644 --- a/src/models/policy_mfa_factors.rs +++ b/src/models/policy_mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMfaFactors { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether TOTP can be used to complete an MFA challenge. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Whether email can be used to complete an MFA challenge. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Whether phone (SMS) can be used to complete an MFA challenge. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Whether the custom factor can be used to complete an MFA challenge. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_totp() -> bool { + true +} + +fn default_email() -> bool { + true +} + +fn default_phone() -> bool { + true +} + +fn default_custom() -> bool { + false +} + impl PolicyMfaFactors { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_passkey.rs b/src/models/policy_passkey.rs index 3306d5e..e556cbc 100644 --- a/src/models/policy_passkey.rs +++ b/src/models/policy_passkey.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasskey { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Relying party ID passkeys are bound to. Empty until configured. #[serde(rename = "rpId")] + #[serde(default = "default_rp_id")] pub rp_id: String, /// Web origins passkeys work on, from the project's platforms on the relying /// party ID and a localhost web platform. Read-only. #[serde(rename = "origins")] + #[serde(default = "default_origins")] pub origins: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_rp_id() -> String { + "".to_string() +} + +fn default_origins() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyPasskey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_dictionary.rs b/src/models/policy_password_dictionary.rs index e14d27b..2d9857d 100644 --- a/src/models/policy_password_dictionary.rs +++ b/src/models/policy_password_dictionary.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordDictionary { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password dictionary policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordDictionary { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_history.rs b/src/models/policy_password_history.rs index 6f00db0..e356b25 100644 --- a/src/models/policy_password_history.rs +++ b/src/models/policy_password_history.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordHistory { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Password history length. A value of 0 means the policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyPasswordHistory { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_personal_data.rs b/src/models/policy_password_personal_data.rs index 6fee0df..9b19000 100644 --- a/src/models/policy_password_personal_data.rs +++ b/src/models/policy_password_personal_data.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordPersonalData { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password personal data policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordPersonalData { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_strength.rs b/src/models/policy_password_strength.rs index fa3b56a..08ff7bb 100644 --- a/src/models/policy_password_strength.rs +++ b/src/models/policy_password_strength.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordStrength { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Minimum password length required for user passwords. #[serde(rename = "min")] + #[serde(default = "default_min")] pub min: i64, /// Whether passwords must include at least one uppercase letter. #[serde(rename = "uppercase")] + #[serde(default = "default_uppercase")] pub uppercase: bool, /// Whether passwords must include at least one lowercase letter. #[serde(rename = "lowercase")] + #[serde(default = "default_lowercase")] pub lowercase: bool, /// Whether passwords must include at least one number. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: bool, /// Whether passwords must include at least one symbol. #[serde(rename = "symbols")] + #[serde(default = "default_symbols")] pub symbols: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_min() -> i64 { + 8 +} + +fn default_uppercase() -> bool { + false +} + +fn default_lowercase() -> bool { + false +} + +fn default_number() -> bool { + false +} + +fn default_symbols() -> bool { + false +} + impl PolicyPasswordStrength { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_alert.rs b/src/models/policy_session_alert.rs index 3689003..84ebba2 100644 --- a/src/models/policy_session_alert.rs +++ b/src/models/policy_session_alert.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionAlert { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session alert policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicySessionAlert { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_duration.rs b/src/models/policy_session_duration.rs index 4cf1a79..93e96dc 100644 --- a/src/models/policy_session_duration.rs +++ b/src/models/policy_session_duration.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionDuration { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session duration in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_duration() -> i64 { + 31536000 +} + impl PolicySessionDuration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_invalidation.rs b/src/models/policy_session_invalidation.rs index 07846c9..f63d898 100644 --- a/src/models/policy_session_invalidation.rs +++ b/src/models/policy_session_invalidation.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionInvalidation { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session invalidation policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + impl PolicySessionInvalidation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_limit.rs b/src/models/policy_session_limit.rs index 86f066f..c6b02b8 100644 --- a/src/models/policy_session_limit.rs +++ b/src/models/policy_session_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of sessions allowed per user. A value of 0 means the policy /// is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicySessionLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_user_limit.rs b/src/models/policy_user_limit.rs index 4515afd..84b0359 100644 --- a/src/models/policy_user_limit.rs +++ b/src/models/policy_user_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicyUserLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of users allowed in the project. A value of 0 means the /// policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyUserLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/postgres_extension.rs b/src/models/postgres_extension.rs index 6fa2b95..8e2cb31 100644 --- a/src/models/postgres_extension.rs +++ b/src/models/postgres_extension.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct PostgresExtension { /// Extension key used with CREATE EXTENSION. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Human-readable extension name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Short description of what the extension provides. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Category the extension belongs to. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + impl PostgresExtension { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/presence.rs b/src/models/presence.rs index 5ed34d4..845310e 100644 --- a/src/models/presence.rs +++ b/src/models/presence.rs @@ -8,19 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct Presence { /// Presence ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Presence creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Presence update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Presence permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Presence status. #[serde(rename = "status")] @@ -28,6 +33,7 @@ pub struct Presence { pub status: Option, /// Presence source. #[serde(rename = "source")] + #[serde(default = "default_source")] pub source: String, /// Presence expiry date in ISO 8601 format. #[serde(rename = "expiresAt")] @@ -39,6 +45,30 @@ pub struct Presence { pub metadata: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_source() -> String { + "".to_string() +} + impl Presence { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/presence_list.rs b/src/models/presence_list.rs index 0257bf7..6a006b2 100644 --- a/src/models/presence_list.rs +++ b/src/models/presence_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PresenceList { /// Total number of presences that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of presences. #[serde(rename = "presences")] + #[serde(default = "default_presences")] pub presences: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_presences() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PresenceList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/program.rs b/src/models/program.rs index 588d509..06eedf7 100644 --- a/src/models/program.rs +++ b/src/models/program.rs @@ -8,33 +8,78 @@ use serde::{Deserialize, Serialize}; pub struct Program { /// Program ID #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Program title #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Program description #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Program tag for highlighting on console #[serde(rename = "tag")] + #[serde(default = "default_tag")] pub tag: String, /// Program icon for highlighting on console #[serde(rename = "icon")] + #[serde(default = "default_icon")] pub icon: String, /// URL for more information on this program #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Whether this program is active #[serde(rename = "active")] + #[serde(default = "default_active")] pub active: bool, /// Whether this program is external #[serde(rename = "external")] + #[serde(default = "default_external")] pub external: bool, /// Billing plan ID that this is program is associated with. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_tag() -> String { + "".to_string() +} + +fn default_icon() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_active() -> bool { + true +} + +fn default_external() -> bool { + true +} + +fn default_billing_plan_id() -> String { + "".to_string() +} + impl Program { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/project.rs b/src/models/project.rs index 78a7fc7..962b910 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -8,87 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Project creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Project update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Project team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Project region #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, - /// Deprecated since 1.9.5: List of dev keys. - #[serde(rename = "devKeys")] - pub dev_keys: Vec, /// Status for custom SMTP #[serde(rename = "smtpEnabled")] + #[serde(default = "default_smtp_enabled")] pub smtp_enabled: bool, /// SMTP sender name #[serde(rename = "smtpSenderName")] + #[serde(default = "default_smtp_sender_name")] pub smtp_sender_name: String, /// SMTP sender email #[serde(rename = "smtpSenderEmail")] + #[serde(default = "default_smtp_sender_email")] pub smtp_sender_email: String, /// SMTP reply to name #[serde(rename = "smtpReplyToName")] + #[serde(default = "default_smtp_reply_to_name")] pub smtp_reply_to_name: String, /// SMTP reply to email #[serde(rename = "smtpReplyToEmail")] + #[serde(default = "default_smtp_reply_to_email")] pub smtp_reply_to_email: String, /// SMTP server host name #[serde(rename = "smtpHost")] + #[serde(default = "default_smtp_host")] pub smtp_host: String, /// SMTP server port #[serde(rename = "smtpPort")] + #[serde(default = "default_smtp_port")] pub smtp_port: i64, /// SMTP server username #[serde(rename = "smtpUsername")] + #[serde(default = "default_smtp_username")] pub smtp_username: String, /// SMTP server password. This property is write-only and always returned /// empty. #[serde(rename = "smtpPassword")] + #[serde(default = "default_smtp_password")] pub smtp_password: String, /// SMTP server secure protocol #[serde(rename = "smtpSecure")] + #[serde(default = "default_smtp_secure")] pub smtp_secure: String, /// Number of times the ping was received for this project. #[serde(rename = "pingCount")] + #[serde(default = "default_ping_count")] pub ping_count: i64, /// Last ping datetime in ISO 8601 format. #[serde(rename = "pingedAt")] + #[serde(default = "default_pinged_at")] pub pinged_at: String, /// Labels for the project. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Project status #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Stage progress (completed or skipped) with timestamps and actor types, /// keyed by stage id. #[serde(rename = "onboarding")] + #[serde(default = "default_onboarding")] pub onboarding: serde_json::Value, /// List of auth methods. #[serde(rename = "authMethods")] + #[serde(default = "default_auth_methods")] pub auth_methods: Vec, /// List of services. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// List of protocols. #[serde(rename = "protocols")] + #[serde(default = "default_protocols")] pub protocols: Vec, /// Project blocks information #[serde(rename = "blocks")] + #[serde(default = "default_blocks")] pub blocks: Vec, /// Last time the project was accessed via console. Used with plan's /// projectInactivityDays to determine if project is paused. #[serde(rename = "consoleAccessedAt")] + #[serde(default = "default_console_accessed_at")] pub console_accessed_at: String, /// Whether WAF enforcement is enabled for the project. #[serde(rename = "wafEnabled")] @@ -192,6 +215,110 @@ pub struct Project { pub o_auth2_server_discovery_url: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "fra".to_string() +} + +fn default_smtp_enabled() -> bool { + false +} + +fn default_smtp_sender_name() -> String { + "".to_string() +} + +fn default_smtp_sender_email() -> String { + "".to_string() +} + +fn default_smtp_reply_to_name() -> String { + "".to_string() +} + +fn default_smtp_reply_to_email() -> String { + "".to_string() +} + +fn default_smtp_host() -> String { + "".to_string() +} + +fn default_smtp_port() -> i64 { + 0 +} + +fn default_smtp_username() -> String { + "".to_string() +} + +fn default_smtp_password() -> String { + "".to_string() +} + +fn default_smtp_secure() -> String { + "".to_string() +} + +fn default_ping_count() -> i64 { + 0 +} + +fn default_pinged_at() -> String { + "".to_string() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_onboarding() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_auth_methods() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_protocols() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_blocks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_console_accessed_at() -> String { + "".to_string() +} + impl Project { /// Get id pub fn id(&self) -> &String { @@ -223,11 +350,6 @@ impl Project { &self.region } - /// Get dev_keys - pub fn dev_keys(&self) -> &Vec { - &self.dev_keys - } - /// Get smtp_enabled pub fn smtp_enabled(&self) -> &bool { &self.smtp_enabled @@ -634,7 +756,6 @@ mod tests { let _ = _model.name(); let _ = _model.team_id(); let _ = _model.region(); - let _ = _model.dev_keys(); let _ = _model.smtp_enabled(); let _ = _model.smtp_sender_name(); let _ = _model.smtp_sender_email(); diff --git a/src/models/project_auth_method.rs b/src/models/project_auth_method.rs index e8428f1..37f1ef8 100644 --- a/src/models/project_auth_method.rs +++ b/src/models/project_auth_method.rs @@ -11,9 +11,14 @@ pub struct ProjectAuthMethod { pub id: crate::enums::ProjectAuthMethodId, /// Auth method status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectAuthMethod { /// Get id pub fn id(&self) -> &crate::enums::ProjectAuthMethodId { diff --git a/src/models/project_list.rs b/src/models/project_list.rs index 9bcda60..83f9fdc 100644 --- a/src/models/project_list.rs +++ b/src/models/project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/project_protocol.rs b/src/models/project_protocol.rs index a8bd9e1..82cf49e 100644 --- a/src/models/project_protocol.rs +++ b/src/models/project_protocol.rs @@ -11,9 +11,14 @@ pub struct ProjectProtocol { pub id: crate::enums::ProjectProtocolId, /// Protocol status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectProtocol { /// Get id pub fn id(&self) -> &crate::enums::ProjectProtocolId { diff --git a/src/models/project_service.rs b/src/models/project_service.rs index 4d94d38..7601ae4 100644 --- a/src/models/project_service.rs +++ b/src/models/project_service.rs @@ -11,9 +11,14 @@ pub struct ProjectService { pub id: crate::enums::ProjectServiceId, /// Service status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectService { /// Get id pub fn id(&self) -> &crate::enums::ProjectServiceId { diff --git a/src/models/provider.rs b/src/models/provider.rs index 6da6a12..0730ec8 100644 --- a/src/models/provider.rs +++ b/src/models/provider.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Provider { /// Provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Provider creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Provider update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name for the provider instance. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// The name of the provider service. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Is provider enabled? #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Type of provider. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Provider credentials. #[serde(rename = "credentials")] + #[serde(default = "default_credentials")] pub credentials: serde_json::Value, /// Provider options. #[serde(rename = "options")] @@ -36,6 +44,38 @@ pub struct Provider { pub options: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "".to_string() +} + +fn default_credentials() -> serde_json::Value { + serde_json::json!({}) +} + impl Provider { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/provider_list.rs b/src/models/provider_list.rs index 3d9c5c9..8d6e077 100644 --- a/src/models/provider_list.rs +++ b/src/models/provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProviderList { /// Total number of providers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/proxy_invalidation.rs b/src/models/proxy_invalidation.rs index eaec944..575f927 100644 --- a/src/models/proxy_invalidation.rs +++ b/src/models/proxy_invalidation.rs @@ -8,19 +8,39 @@ use serde::{Deserialize, Serialize}; pub struct ProxyInvalidation { /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Invalidation type. Possible values are "tag", "path", or "all". #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Invalidated reference. Depending on type this is a cache tag name, a URL /// path, or empty when type is all. #[serde(rename = "reference")] + #[serde(default = "default_reference")] pub reference: String, /// Invalidation status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, } +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_reference() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl ProxyInvalidation { /// Get domain pub fn domain(&self) -> &String { diff --git a/src/models/proxy_rule.rs b/src/models/proxy_rule.rs index 1082f77..98d4390 100644 --- a/src/models/proxy_rule.rs +++ b/src/models/proxy_rule.rs @@ -8,56 +8,128 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRule { /// Rule ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Rule creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Rule update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Action definition for the rule. Possible values are "api", "deployment", or /// "redirect" #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Defines how the rule was created. Possible values are "manual" or /// "deployment" #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// URL to redirect to. Used if type is "redirect" #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, /// Status code to apply during redirect. Used if type is "redirect" #[serde(rename = "redirectStatusCode")] + #[serde(default = "default_redirect_status_code")] pub redirect_status_code: i64, /// ID of deployment. Used if type is "deployment" #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, - /// Type of deployment. Possible values are "function", "site". Used if rule's - /// type is "deployment". + /// Type of deployment resource: function, site, or dedicatedDatabase. #[serde(rename = "deploymentResourceType")] #[serde(skip_serializing_if = "Option::is_none")] pub deployment_resource_type: Option, /// ID of deployment's resource (site or function ID). Used if type is /// "deployment" #[serde(rename = "deploymentResourceId")] + #[serde(default = "default_deployment_resource_id")] pub deployment_resource_id: String, /// Name of Git branch that updates rule. Used if type is "deployment" #[serde(rename = "deploymentVcsProviderBranch")] + #[serde(default = "default_deployment_vcs_provider_branch")] pub deployment_vcs_provider_branch: String, /// Domain verification status. Possible values are "unverified", "verifying", /// "verified" #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::ProxyRuleStatus, /// Logs from rule verification or certificate generation. Certificate /// generation logs are prioritized if both are available. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Certificate auto-renewal date in ISO 8601 format. #[serde(rename = "renewAt")] pub renew_at: String, + /// Ingress protocol for the rule. + #[serde(rename = "protocol")] + #[serde(default = "default_protocol")] + pub protocol: crate::enums::ProxyRuleProtocol, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + +fn default_redirect_status_code() -> i64 { + 301 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_resource_id() -> String { + "".to_string() +} + +fn default_deployment_vcs_provider_branch() -> String { + "".to_string() +} + +fn default_status() -> crate::enums::ProxyRuleStatus { + serde_json::from_value(serde_json::json!("unverified")).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_protocol() -> crate::enums::ProxyRuleProtocol { + serde_json::from_value(serde_json::json!("http")).unwrap() } impl ProxyRule { @@ -146,6 +218,11 @@ impl ProxyRule { pub fn renew_at(&self) -> &String { &self.renew_at } + + /// Get protocol + pub fn protocol(&self) -> &crate::enums::ProxyRuleProtocol { + &self.protocol + } } #[cfg(test)] @@ -169,6 +246,7 @@ mod tests { let _ = _model.status(); let _ = _model.logs(); let _ = _model.renew_at(); + let _ = _model.protocol(); } #[test] diff --git a/src/models/proxy_rule_list.rs b/src/models/proxy_rule_list.rs index ddd137d..e6ac600 100644 --- a/src/models/proxy_rule_list.rs +++ b/src/models/proxy_rule_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRuleList { /// Total number of rules that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rules. #[serde(rename = "rules")] + #[serde(default = "default_rules")] pub rules: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rules() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProxyRuleList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/report.rs b/src/models/report.rs index 4f43770..f1992ae 100644 --- a/src/models/report.rs +++ b/src/models/report.rs @@ -8,38 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Report { /// Report ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Report creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Report update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the third-party app that submitted the report. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Analyzer that produced this report. e.g. lighthouse, audit, /// databaseAnalyzer. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Short, human-readable title for the report. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Markdown summary describing the report. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// Plural noun describing what the report analyzes, e.g. databases, sites, /// urls. #[serde(rename = "targetType")] + #[serde(default = "default_target_type")] pub target_type: String, /// Free-form target identifier (URL for lighthouse, resource ID for db). #[serde(rename = "target")] + #[serde(default = "default_target")] pub target: String, /// Categories covered by the report, e.g. performance, accessibility. #[serde(rename = "categories")] + #[serde(default = "default_categories")] pub categories: Vec, /// Insights nested under this report. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, /// Time the report was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -47,6 +58,50 @@ pub struct Report { pub analyzed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_target_type() -> String { + "".to_string() +} + +fn default_target() -> String { + "".to_string() +} + +fn default_categories() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Report { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/report_list.rs b/src/models/report_list.rs index 81b4995..4c1c5ca 100644 --- a/src/models/report_list.rs +++ b/src/models/report_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ReportList { /// Total number of reports that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of reports. #[serde(rename = "reports")] + #[serde(default = "default_reports")] pub reports: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_reports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ReportList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/resource_token.rs b/src/models/resource_token.rs index 2108383..4efceee 100644 --- a/src/models/resource_token.rs +++ b/src/models/resource_token.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct ResourceToken { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// JWT encoded string. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl ResourceToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/resource_token_list.rs b/src/models/resource_token_list.rs index af45953..de499c1 100644 --- a/src/models/resource_token_list.rs +++ b/src/models/resource_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ResourceTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ResourceTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/row.rs b/src/models/row.rs index 6c50624..308b438 100644 --- a/src/models/row.rs +++ b/src/models/row.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Row { /// Row ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Row sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Table ID. #[serde(rename = "$tableId")] + #[serde(default = "default_table_id")] pub table_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Row creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Row update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Row permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_table_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Row { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/row_list.rs b/src/models/row_list.rs index ff8047e..1ec0e23 100644 --- a/src/models/row_list.rs +++ b/src/models/row_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RowList { /// Total number of rows that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rows. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RowList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/runtime.rs b/src/models/runtime.rs index 71b88a9..d053cb1 100644 --- a/src/models/runtime.rs +++ b/src/models/runtime.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct Runtime { /// Runtime ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Parent runtime key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Runtime Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Runtime version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Base Docker image used to build the runtime. #[serde(rename = "base")] + #[serde(default = "default_base")] pub base: String, /// Image name of Docker Hub. #[serde(rename = "image")] + #[serde(default = "default_image")] pub image: String, /// Name of the logo image. #[serde(rename = "logo")] + #[serde(default = "default_logo")] pub logo: String, /// List of supported architectures. #[serde(rename = "supports")] + #[serde(default = "default_supports")] pub supports: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_base() -> String { + "".to_string() +} + +fn default_image() -> String { + "".to_string() +} + +fn default_logo() -> String { + "".to_string() +} + +fn default_supports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Runtime { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/runtime_list.rs b/src/models/runtime_list.rs index de7e84b..b45492d 100644 --- a/src/models/runtime_list.rs +++ b/src/models/runtime_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RuntimeList { /// Total number of runtimes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of runtimes. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RuntimeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/session.rs b/src/models/session.rs index 228fc31..3a775e0 100644 --- a/src/models/session.rs +++ b/src/models/session.rs @@ -8,97 +8,242 @@ use serde::{Deserialize, Serialize}; pub struct Session { /// Session ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Session update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Session expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Session Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Session Provider User ID. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Session Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Session Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// IP in use when the session was created. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Operating system code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). #[serde(rename = "osCode")] + #[serde(default = "default_os_code")] pub os_code: String, /// Operating system name. #[serde(rename = "osName")] + #[serde(default = "default_os_name")] pub os_name: String, /// Operating system version. #[serde(rename = "osVersion")] + #[serde(default = "default_os_version")] pub os_version: String, /// Client type. #[serde(rename = "clientType")] + #[serde(default = "default_client_type")] pub client_type: String, /// Client code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). #[serde(rename = "clientCode")] + #[serde(default = "default_client_code")] pub client_code: String, /// Client name. #[serde(rename = "clientName")] + #[serde(default = "default_client_name")] pub client_name: String, /// Client version. #[serde(rename = "clientVersion")] + #[serde(default = "default_client_version")] pub client_version: String, /// Client engine name. #[serde(rename = "clientEngine")] + #[serde(default = "default_client_engine")] pub client_engine: String, /// Client engine name. #[serde(rename = "clientEngineVersion")] + #[serde(default = "default_client_engine_version")] pub client_engine_version: String, /// Device name. #[serde(rename = "deviceName")] + #[serde(default = "default_device_name")] pub device_name: String, /// Device brand name. #[serde(rename = "deviceBrand")] + #[serde(default = "default_device_brand")] pub device_brand: String, /// Device model name. #[serde(rename = "deviceModel")] + #[serde(default = "default_device_model")] pub device_model: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, /// Returns true if this the current user session. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: bool, /// Returns a list of active session factors. #[serde(rename = "factors")] + #[serde(default = "default_factors")] pub factors: Vec, /// Secret used to authenticate the user. Only included if the request was made /// with an API key #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent date in ISO 8601 format when the session successfully passed /// MFA challenge. #[serde(rename = "mfaUpdatedAt")] + #[serde(default = "default_mfa_updated_at")] pub mfa_updated_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_os_code() -> String { + "".to_string() +} + +fn default_os_name() -> String { + "".to_string() +} + +fn default_os_version() -> String { + "".to_string() +} + +fn default_client_type() -> String { + "".to_string() +} + +fn default_client_code() -> String { + "".to_string() +} + +fn default_client_name() -> String { + "".to_string() +} + +fn default_client_version() -> String { + "".to_string() +} + +fn default_client_engine() -> String { + "".to_string() +} + +fn default_client_engine_version() -> String { + "".to_string() +} + +fn default_device_name() -> String { + "".to_string() +} + +fn default_device_brand() -> String { + "".to_string() +} + +fn default_device_model() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + +fn default_current() -> bool { + false +} + +fn default_factors() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_mfa_updated_at() -> String { + "".to_string() +} + impl Session { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/session_list.rs b/src/models/session_list.rs index 8e912c5..f74e7d3 100644 --- a/src/models/session_list.rs +++ b/src/models/session_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SessionList { /// Total number of sessions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sessions. #[serde(rename = "sessions")] + #[serde(default = "default_sessions")] pub sessions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sessions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SessionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/site.rs b/src/models/site.rs index 4cb6f80..a1f7723 100644 --- a/src/models/site.rs +++ b/src/models/site.rs @@ -8,112 +8,145 @@ use serde::{Deserialize, Serialize}; pub struct Site { /// Site ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Site creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Site update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Site name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Site enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the site deployed with the latest configuration? This is set to false if /// you've changed an environment variables, entrypoint, commands, or other /// settings that needs redeploy to be applied. When the value is false, /// redeploy the site to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, request logs will exclude logs and errors, and site /// responses will be slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Site framework. #[serde(rename = "framework")] + #[serde(default = "default_framework")] pub framework: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Site's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Screenshot of active deployment with light theme preference file ID. #[serde(rename = "deploymentScreenshotLight")] + #[serde(default = "default_deployment_screenshot_light")] pub deployment_screenshot_light: String, /// Screenshot of active deployment with dark theme preference file ID. #[serde(rename = "deploymentScreenshotDark")] + #[serde(default = "default_deployment_screenshot_dark")] pub deployment_screenshot_dark: String, /// Site's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Site variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Site request timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The install command used to install the site dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// The build command used to build the site. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Custom command to use when starting site runtime. #[serde(rename = "startCommand")] + #[serde(default = "default_start_command")] pub start_command: String, /// The directory where the site build output is located. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Site VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to site in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for SSR executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, /// Site build runtime. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// Site framework adapter. #[serde(rename = "adapter")] @@ -124,6 +157,138 @@ pub struct Site { pub fallback_file: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_framework() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_deployment_screenshot_light() -> String { + "".to_string() +} + +fn default_deployment_screenshot_dark() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_start_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + impl Site { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/site_list.rs b/src/models/site_list.rs index 1525368..ac1e2eb 100644 --- a/src/models/site_list.rs +++ b/src/models/site_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SiteList { /// Total number of sites that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sites. #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sites() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SiteList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/specification.rs b/src/models/specification.rs index 1cbb8a2..006eaf5 100644 --- a/src/models/specification.rs +++ b/src/models/specification.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Specification { /// Memory size in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Number of CPUs. #[serde(rename = "cpus")] + #[serde(default = "default_cpus")] pub cpus: f64, /// Is size enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Size slug. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, } +fn default_memory() -> i64 { + 0 +} + +fn default_cpus() -> f64 { + 0.0 +} + +fn default_enabled() -> bool { + false +} + +fn default_slug() -> String { + "".to_string() +} + impl Specification { /// Get memory pub fn memory(&self) -> &i64 { diff --git a/src/models/specification_list.rs b/src/models/specification_list.rs index de28440..887dc11 100644 --- a/src/models/specification_list.rs +++ b/src/models/specification_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SpecificationList { /// Total number of specifications that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SpecificationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/subscriber.rs b/src/models/subscriber.rs index 00b5d42..ed5a3b1 100644 --- a/src/models/subscriber.rs +++ b/src/models/subscriber.rs @@ -8,34 +8,74 @@ use serde::{Deserialize, Serialize}; pub struct Subscriber { /// Subscriber ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Subscriber creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Subscriber update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target ID. #[serde(rename = "targetId")] + #[serde(default = "default_target_id")] pub target_id: String, /// Target. #[serde(rename = "target")] pub target: crate::models::Target, /// Topic ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User Name. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// Topic ID. #[serde(rename = "topicId")] + #[serde(default = "default_topic_id")] pub topic_id: String, /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_target_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_topic_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + impl Subscriber { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/subscriber_list.rs b/src/models/subscriber_list.rs index 045c977..64636fe 100644 --- a/src/models/subscriber_list.rs +++ b/src/models/subscriber_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SubscriberList { /// Total number of subscribers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of subscribers. #[serde(rename = "subscribers")] + #[serde(default = "default_subscribers")] pub subscribers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_subscribers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SubscriberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/table.rs b/src/models/table.rs index 82cb1f0..1c33993 100644 --- a/src/models/table.rs +++ b/src/models/table.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Table { /// Table ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Table creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Table update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Table permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Table name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is /// inaccessible to users, but remains accessible to Server SDKs using API /// keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether row-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "rowSecurity")] + #[serde(default = "default_row_security")] pub row_security: bool, /// Table columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Table indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum row size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used row size in bytes based on defined columns. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_row_security() -> bool { + false +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Table { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/table_list.rs b/src/models/table_list.rs index 73748c1..53c23be 100644 --- a/src/models/table_list.rs +++ b/src/models/table_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TableList { /// Total number of tables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tables. #[serde(rename = "tables")] + #[serde(default = "default_tables")] pub tables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/target.rs b/src/models/target.rs index 79d2dc8..7bec4f4 100644 --- a/src/models/target.rs +++ b/src/models/target.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Target { /// Target ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Target creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Target update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Provider ID. #[serde(rename = "providerId")] @@ -28,15 +33,50 @@ pub struct Target { /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// The target identifier. #[serde(rename = "identifier")] + #[serde(default = "default_identifier")] pub identifier: String, /// Is the target expired. #[serde(rename = "expired")] + #[serde(default = "default_expired")] pub expired: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_identifier() -> String { + "".to_string() +} + +fn default_expired() -> bool { + false +} + impl Target { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/target_list.rs b/src/models/target_list.rs index a3edee5..0c7f169 100644 --- a/src/models/target_list.rs +++ b/src/models/target_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TargetList { /// Total number of targets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of targets. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TargetList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/team.rs b/src/models/team.rs index b951756..7da273c 100644 --- a/src/models/team.rs +++ b/src/models/team.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Team { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] pub prefs: crate::models::Preferences, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl Team { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/team_list.rs b/src/models/team_list.rs index d1df58e..f128b40 100644 --- a/src/models/team_list.rs +++ b/src/models/team_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TeamList { /// Total number of teams that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of teams. #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_teams() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TeamList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/token.rs b/src/models/token.rs index 89f96f4..903214a 100644 --- a/src/models/token.rs +++ b/src/models/token.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct Token { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. This will return an empty string unless the response is /// returned using an API key or as part of a webhook payload. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl Token { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/token_secret.rs b/src/models/token_secret.rs index 442416e..de2563e 100644 --- a/src/models/token_secret.rs +++ b/src/models/token_secret.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct TokenSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. Exchange it for a session with the create session /// endpoint. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl TokenSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic.rs b/src/models/topic.rs index 976d41b..ea701c4 100644 --- a/src/models/topic.rs +++ b/src/models/topic.rs @@ -8,39 +8,81 @@ use serde::{Deserialize, Serialize}; pub struct Topic { /// Topic ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Topic creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Topic update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name of the topic. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total count of email subscribers subscribed to the topic. #[serde(rename = "emailTotal")] + #[serde(default = "default_email_total")] pub email_total: i64, /// Total count of SMS subscribers subscribed to the topic. #[serde(rename = "smsTotal")] + #[serde(default = "default_sms_total")] pub sms_total: i64, /// Total count of push subscribers subscribed to the topic. #[serde(rename = "pushTotal")] + #[serde(default = "default_push_total")] pub push_total: i64, /// Subscribe permissions. #[serde(rename = "subscribe")] + #[serde(default = "default_subscribe")] pub subscribe: Vec, /// MQTT QoS for delivery on this topic. Null lets the subscriber choose their /// level. #[serde(rename = "qos")] #[serde(skip_serializing_if = "Option::is_none")] pub qos: Option, - /// Message retention in seconds for offline delivery. + /// Message retention in seconds for offline delivery. Null inherits the lowest + /// expiry of the project's enabled Appwrite providers, or the 7-day ledger + /// window if none sets one. #[serde(rename = "expiry")] #[serde(skip_serializing_if = "Option::is_none")] pub expiry: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_email_total() -> i64 { + 0 +} + +fn default_sms_total() -> i64 { + 0 +} + +fn default_push_total() -> i64 { + 0 +} + +fn default_subscribe() -> Vec { + serde_json::from_value(serde_json::json!(["users"])).unwrap() +} + impl Topic { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic_list.rs b/src/models/topic_list.rs index 824d84b..b7e128d 100644 --- a/src/models/topic_list.rs +++ b/src/models/topic_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TopicList { /// Total number of topics that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of topics. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TopicList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/transaction.rs b/src/models/transaction.rs index bb2272a..e034fe3 100644 --- a/src/models/transaction.rs +++ b/src/models/transaction.rs @@ -8,25 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct Transaction { /// Transaction ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Transaction creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Transaction update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Current status of the transaction. One of: pending, committing, committed, /// rolled_back, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of operations in the transaction. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: i64, /// Expiration time in ISO 8601 format. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_operations() -> i64 { + 0 +} + +fn default_expires_at() -> String { + "".to_string() +} + impl Transaction { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/transaction_list.rs b/src/models/transaction_list.rs index 29cab9e..6ebd9a0 100644 --- a/src/models/transaction_list.rs +++ b/src/models/transaction_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TransactionList { /// Total number of transactions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of transactions. #[serde(rename = "transactions")] + #[serde(default = "default_transactions")] pub transactions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_transactions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TransactionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/usage_billing_plan.rs b/src/models/usage_billing_plan.rs index ab2c459..ead81be 100644 --- a/src/models/usage_billing_plan.rs +++ b/src/models/usage_billing_plan.rs @@ -8,36 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct UsageBillingPlan { /// Bandwidth additional resources #[serde(rename = "bandwidth")] - pub bandwidth: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub bandwidth: Option, /// Executions additional resources #[serde(rename = "executions")] - pub executions: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub executions: Option, /// Member additional resources #[serde(rename = "member")] #[serde(skip_serializing_if = "Option::is_none")] pub member: Option, /// Realtime additional resources #[serde(rename = "realtime")] - pub realtime: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime: Option, /// Realtime messages additional resources #[serde(rename = "realtimeMessages")] - pub realtime_messages: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime_messages: Option, /// Realtime bandwidth additional resources #[serde(rename = "realtimeBandwidth")] #[serde(skip_serializing_if = "Option::is_none")] pub realtime_bandwidth: Option, /// Storage additional resources #[serde(rename = "storage")] - pub storage: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub storage: Option, /// User additional resources #[serde(rename = "users")] - pub users: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub users: Option, /// GBHour additional resources #[serde(rename = "GBHours")] - pub gb_hours: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub gb_hours: Option, /// Image transformation additional resources #[serde(rename = "imageTransformations")] - pub image_transformations: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub image_transformations: Option, /// Credits additional resources #[serde(rename = "credits")] #[serde(skip_serializing_if = "Option::is_none")] @@ -45,14 +53,26 @@ pub struct UsageBillingPlan { } impl UsageBillingPlan { + /// Set bandwidth + pub fn set_bandwidth(mut self, bandwidth: crate::models::AdditionalResource) -> Self { + self.bandwidth = Some(bandwidth); + self + } + /// Get bandwidth - pub fn bandwidth(&self) -> &crate::models::AdditionalResource { - &self.bandwidth + pub fn bandwidth(&self) -> Option<&crate::models::AdditionalResource> { + self.bandwidth.as_ref() + } + + /// Set executions + pub fn set_executions(mut self, executions: crate::models::AdditionalResource) -> Self { + self.executions = Some(executions); + self } /// Get executions - pub fn executions(&self) -> &crate::models::AdditionalResource { - &self.executions + pub fn executions(&self) -> Option<&crate::models::AdditionalResource> { + self.executions.as_ref() } /// Set member @@ -66,14 +86,29 @@ impl UsageBillingPlan { self.member.as_ref() } + /// Set realtime + pub fn set_realtime(mut self, realtime: crate::models::AdditionalResource) -> Self { + self.realtime = Some(realtime); + self + } + /// Get realtime - pub fn realtime(&self) -> &crate::models::AdditionalResource { - &self.realtime + pub fn realtime(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime.as_ref() + } + + /// Set realtime_messages + pub fn set_realtime_messages( + mut self, + realtime_messages: crate::models::AdditionalResource, + ) -> Self { + self.realtime_messages = Some(realtime_messages); + self } /// Get realtime_messages - pub fn realtime_messages(&self) -> &crate::models::AdditionalResource { - &self.realtime_messages + pub fn realtime_messages(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime_messages.as_ref() } /// Set realtime_bandwidth @@ -90,24 +125,51 @@ impl UsageBillingPlan { self.realtime_bandwidth.as_ref() } + /// Set storage + pub fn set_storage(mut self, storage: crate::models::AdditionalResource) -> Self { + self.storage = Some(storage); + self + } + /// Get storage - pub fn storage(&self) -> &crate::models::AdditionalResource { - &self.storage + pub fn storage(&self) -> Option<&crate::models::AdditionalResource> { + self.storage.as_ref() + } + + /// Set users + pub fn set_users(mut self, users: crate::models::AdditionalResource) -> Self { + self.users = Some(users); + self } /// Get users - pub fn users(&self) -> &crate::models::AdditionalResource { - &self.users + pub fn users(&self) -> Option<&crate::models::AdditionalResource> { + self.users.as_ref() + } + + /// Set gb_hours + pub fn set_gb_hours(mut self, gb_hours: crate::models::AdditionalResource) -> Self { + self.gb_hours = Some(gb_hours); + self } /// Get gb_hours - pub fn gb_hours(&self) -> &crate::models::AdditionalResource { - &self.gb_hours + pub fn gb_hours(&self) -> Option<&crate::models::AdditionalResource> { + self.gb_hours.as_ref() + } + + /// Set image_transformations + pub fn set_image_transformations( + mut self, + image_transformations: crate::models::AdditionalResource, + ) -> Self { + self.image_transformations = Some(image_transformations); + self } /// Get image_transformations - pub fn image_transformations(&self) -> &crate::models::AdditionalResource { - &self.image_transformations + pub fn image_transformations(&self) -> Option<&crate::models::AdditionalResource> { + self.image_transformations.as_ref() } /// Set credits @@ -129,14 +191,6 @@ mod tests { #[test] fn test_usage_billing_plan_creation() { let _model = ::default(); - let _ = _model.bandwidth(); - let _ = _model.executions(); - let _ = _model.realtime(); - let _ = _model.realtime_messages(); - let _ = _model.storage(); - let _ = _model.users(); - let _ = _model.gb_hours(); - let _ = _model.image_transformations(); } #[test] diff --git a/src/models/user.rs b/src/models/user.rs index d6e6d2e..9bcaa78 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct User { /// User ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// User creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Hashed user password. #[serde(rename = "password")] @@ -32,24 +36,31 @@ pub struct User { pub hash_options: Option, /// User registration date in ISO 8601 format. #[serde(rename = "registration")] + #[serde(default = "default_registration")] pub registration: String, /// User status. Pass `true` for enabled and `false` for disabled. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: bool, /// Labels for the user. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Password update time in ISO 8601 format. #[serde(rename = "passwordUpdate")] + #[serde(default = "default_password_update")] pub password_update: String, /// User email address. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: String, /// User phone number in E.164 format. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: String, /// Email verification status. #[serde(rename = "emailVerification")] + #[serde(default = "default_email_verification")] pub email_verification: bool, /// Canonical form of the user email address. #[serde(rename = "emailCanonical")] @@ -78,9 +89,11 @@ pub struct User { pub password_pwned: Option, /// Phone verification status. #[serde(rename = "phoneVerification")] + #[serde(default = "default_phone_verification")] pub phone_verification: bool, /// Multi factor authentication status. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// User preferences as a key-value object #[serde(rename = "prefs")] @@ -88,10 +101,12 @@ pub struct User { /// A user-owned message receiver. A single user may have multiple e.g. emails, /// phones, and a browser. Each target is registered with a single provider. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// Whether the user can impersonate other users. #[serde(rename = "impersonator")] @@ -106,6 +121,66 @@ pub struct User { pub impersonator_user_id: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_registration() -> String { + "".to_string() +} + +fn default_status() -> bool { + true +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_password_update() -> String { + "".to_string() +} + +fn default_email() -> String { + "".to_string() +} + +fn default_phone() -> String { + "".to_string() +} + +fn default_email_verification() -> bool { + false +} + +fn default_phone_verification() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl User { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/user_list.rs b/src/models/user_list.rs index a6e27f4..16c8f64 100644 --- a/src/models/user_list.rs +++ b/src/models/user_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct UserList { /// Total number of users that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of users. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl UserList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/variable.rs b/src/models/variable.rs index cadb289..b27a858 100644 --- a/src/models/variable.rs +++ b/src/models/variable.rs @@ -8,33 +8,73 @@ use serde::{Deserialize, Serialize}; pub struct Variable { /// Variable ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Variable key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Variable value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Variable secret flag. Secret variables can only be updated or deleted, but /// never read. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: bool, /// Service to which the variable belongs. Possible values are "project", /// "function" #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of resource to which the variable belongs. If resourceType is "project", /// it is empty. If resourceType is "function", it is ID of the function. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + +fn default_secret() -> bool { + false +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + impl Variable { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/variable_list.rs b/src/models/variable_list.rs index 9720690..3c3a8bf 100644 --- a/src/models/variable_list.rs +++ b/src/models/variable_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VariableList { /// Total number of variables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of variables. #[serde(rename = "variables")] + #[serde(default = "default_variables")] pub variables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_variables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VariableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/vectorsdb_collection.rs b/src/models/vectorsdb_collection.rs index f352907..38e0c83 100644 --- a/src/models/vectorsdb_collection.rs +++ b/src/models/vectorsdb_collection.rs @@ -8,49 +8,114 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, /// Embedding dimension. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + +fn default_dimension() -> i64 { + 0 +} + impl VectorsdbCollection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/vectorsdb_collection_list.rs b/src/models/vectorsdb_collection_list.rs index 719dfca..09c5647 100644 --- a/src/models/vectorsdb_collection_list.rs +++ b/src/models/vectorsdb_collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VectorsdbCollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/webhook.rs b/src/models/webhook.rs index 5e398a3..3875de3 100644 --- a/src/models/webhook.rs +++ b/src/models/webhook.rs @@ -8,46 +8,111 @@ use serde::{Deserialize, Serialize}; pub struct Webhook { /// Webhook ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Webhook creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Webhook update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Webhook name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Webhook URL endpoint. #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Webhook trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Indicates if SSL / TLS certificate verification is enabled. #[serde(rename = "tls")] + #[serde(default = "default_tls")] pub tls: bool, /// HTTP basic authentication username. #[serde(rename = "authUsername")] + #[serde(default = "default_auth_username")] pub auth_username: String, - /// HTTP basic authentication password. + /// HTTP basic authentication password. Write-only: always returned empty. #[serde(rename = "authPassword")] + #[serde(default = "default_auth_password")] pub auth_password: String, /// Signature key which can be used to validate incoming webhook payloads. Only /// returned on creation and secret rotation. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Indicates if this webhook is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Webhook error logs from the most recent failure. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Number of consecutive failed webhook attempts. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tls() -> bool { + true +} + +fn default_auth_username() -> String { + "".to_string() +} + +fn default_auth_password() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + impl Webhook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/webhook_list.rs b/src/models/webhook_list.rs index 29d04f7..d9602c4 100644 --- a/src/models/webhook_list.rs +++ b/src/models/webhook_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct WebhookList { /// Total number of webhooks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of webhooks. #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_webhooks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl WebhookList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/query/builder.rs b/src/query/builder.rs new file mode 100644 index 0000000..ea55fad --- /dev/null +++ b/src/query/builder.rs @@ -0,0 +1,622 @@ +use serde::Serialize; +use serde_json::Value; + +use super::Query; + +#[derive(Debug, Clone, Default)] +pub struct Builder { + queries: Vec, +} + +impl Builder { + pub fn new() -> Self { + Self { + queries: Vec::new(), + } + } + + pub fn build(&self) -> Vec { + self.queries.iter().map(|query| query.to_string()).collect() + } + + pub fn equal, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::equal(attribute, value)); + self + } + + pub fn not_equal, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::not_equal(attribute, value)); + self + } + + pub fn less_than, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::less_than(attribute, value)); + self + } + + pub fn less_than_equal, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries.push(Query::less_than_equal(attribute, value)); + self + } + + pub fn greater_than, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::greater_than(attribute, value)); + self + } + + pub fn greater_than_equal, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries + .push(Query::greater_than_equal(attribute, value)); + self + } + + pub fn is_null>(mut self, attribute: S) -> Self { + self.queries.push(Query::is_null(attribute)); + self + } + + pub fn is_not_null>(mut self, attribute: S) -> Self { + self.queries.push(Query::is_not_null(attribute)); + self + } + + pub fn between, V: Into>( + mut self, + attribute: S, + start: V, + end: V, + ) -> Self { + self.queries.push(Query::between(attribute, start, end)); + self + } + + pub fn starts_with, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::starts_with(attribute, value)); + self + } + + pub fn ends_with, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::ends_with(attribute, value)); + self + } + + pub fn select, S: Into>(mut self, attributes: I) -> Self { + self.queries.push(Query::select(attributes)); + self + } + + pub fn search, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::search(attribute, value)); + self + } + + pub fn not_search, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::not_search(attribute, value)); + self + } + + pub fn order_asc>(mut self, attribute: S) -> Self { + self.queries.push(Query::order_asc(attribute)); + self + } + + pub fn order_desc>(mut self, attribute: S) -> Self { + self.queries.push(Query::order_desc(attribute)); + self + } + + pub fn order_random(mut self) -> Self { + self.queries.push(Query::order_random()); + self + } + + pub fn cursor_after>(mut self, document_id: S) -> Self { + self.queries.push(Query::cursor_after(document_id)); + self + } + + pub fn cursor_before>(mut self, document_id: S) -> Self { + self.queries.push(Query::cursor_before(document_id)); + self + } + + pub fn limit(mut self, value: u32) -> Self { + self.queries.push(Query::limit(value)); + self + } + + pub fn offset(mut self, value: u32) -> Self { + self.queries.push(Query::offset(value)); + self + } + + pub fn contains, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::contains(attribute, value)); + self + } + + pub fn contains_any, V: Into>( + mut self, + attribute: S, + values: Vec, + ) -> Self { + self.queries.push(Query::contains_any(attribute, values)); + self + } + + pub fn contains_all, V: Into>( + mut self, + attribute: S, + values: Vec, + ) -> Self { + self.queries.push(Query::contains_all(attribute, values)); + self + } + + pub fn not_contains, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::not_contains(attribute, value)); + self + } + + pub fn not_between, V: Into>( + mut self, + attribute: S, + start: V, + end: V, + ) -> Self { + self.queries.push(Query::not_between(attribute, start, end)); + self + } + + pub fn not_starts_with, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries.push(Query::not_starts_with(attribute, value)); + self + } + + pub fn not_ends_with, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries.push(Query::not_ends_with(attribute, value)); + self + } + + pub fn created_before>(mut self, value: V) -> Self { + self.queries.push(Query::created_before(value)); + self + } + + pub fn created_after>(mut self, value: V) -> Self { + self.queries.push(Query::created_after(value)); + self + } + + pub fn created_between>(mut self, start: V, end: V) -> Self { + self.queries.push(Query::created_between(start, end)); + self + } + + pub fn updated_before>(mut self, value: V) -> Self { + self.queries.push(Query::updated_before(value)); + self + } + + pub fn updated_after>(mut self, value: V) -> Self { + self.queries.push(Query::updated_after(value)); + self + } + + pub fn updated_between>(mut self, start: V, end: V) -> Self { + self.queries.push(Query::updated_between(start, end)); + self + } + + pub fn distance_equal, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries + .push(Query::distance_equal(attribute, values, distance, meters)); + self + } + + pub fn distance_not_equal, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries.push(Query::distance_not_equal( + attribute, values, distance, meters, + )); + self + } + + pub fn distance_greater_than, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries.push(Query::distance_greater_than( + attribute, values, distance, meters, + )); + self + } + + pub fn distance_less_than, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries.push(Query::distance_less_than( + attribute, values, distance, meters, + )); + self + } + + pub fn intersects, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::intersects(attribute, values)); + self + } + + pub fn not_intersects, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries.push(Query::not_intersects(attribute, values)); + self + } + + pub fn crosses, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::crosses(attribute, values)); + self + } + + pub fn not_crosses, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::not_crosses(attribute, values)); + self + } + + pub fn overlaps, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::overlaps(attribute, values)); + self + } + + pub fn not_overlaps, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries.push(Query::not_overlaps(attribute, values)); + self + } + + pub fn touches, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::touches(attribute, values)); + self + } + + pub fn not_touches, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::not_touches(attribute, values)); + self + } + + pub fn or(mut self, queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::or(queries)); + self + } + + pub fn and(mut self, queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::and(queries)); + self + } + + pub fn regex, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::regex(attribute, value)); + self + } + + pub fn exists>(mut self, attributes: Vec) -> Self { + self.queries.push(Query::exists(attributes)); + self + } + + pub fn not_exists>(mut self, attributes: Vec) -> Self { + self.queries.push(Query::not_exists(attributes)); + self + } + + pub fn elem_match(mut self, attribute: S, queries: I) -> Self + where + S: Into, + I: IntoIterator, + Q: AsRef, + { + self.queries.push(Query::elem_match(attribute, queries)); + self + } + + pub fn relationship(mut self, attribute: S, queries: I) -> Self + where + S: Into, + I: IntoIterator, + Q: AsRef, + { + self.queries.push(Query::relationship(attribute, queries)); + self + } + + pub fn count(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::count(attribute, alias)); + self + } + + pub fn count_distinct( + mut self, + attribute: impl Into, + alias: impl Into, + ) -> Self { + self.queries.push(Query::count_distinct(attribute, alias)); + self + } + + pub fn sum(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::sum(attribute, alias)); + self + } + + pub fn avg(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::avg(attribute, alias)); + self + } + + pub fn min(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::min(attribute, alias)); + self + } + + pub fn max(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::max(attribute, alias)); + self + } + + pub fn stddev(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::stddev(attribute, alias)); + self + } + + pub fn stddev_pop(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::stddev_pop(attribute, alias)); + self + } + + pub fn stddev_samp(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::stddev_samp(attribute, alias)); + self + } + + pub fn variance(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::variance(attribute, alias)); + self + } + + pub fn var_pop(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::var_pop(attribute, alias)); + self + } + + pub fn var_samp(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::var_samp(attribute, alias)); + self + } + + pub fn bit_and(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::bit_and(attribute, alias)); + self + } + + pub fn bit_or(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::bit_or(attribute, alias)); + self + } + + pub fn bit_xor(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::bit_xor(attribute, alias)); + self + } + + pub fn group_by(mut self, attributes: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.queries.push(Query::group_by(attributes)); + self + } + + pub fn having(mut self, queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::having(queries)); + self + } + + pub fn distinct(mut self) -> Self { + self.queries.push(Query::distinct()); + self + } + + pub fn join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::join(table, left, right, operator, alias)); + self + } + + pub fn left_join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::left_join(table, left, right, operator, alias)); + self + } + + pub fn left_join_on( + mut self, + table: impl Into, + alias: impl Into, + on: I, + ) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::left_join_on(table, alias, on)); + self + } + + pub fn right_join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::right_join(table, left, right, operator, alias)); + self + } + + pub fn full_outer_join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::full_outer_join(table, left, right, operator, alias)); + self + } + + pub fn cross_join(mut self, table: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::cross_join(table, alias)); + self + } + + pub fn vector_dot, N: Into>( + mut self, + attribute: S, + vector: Vec, + ) -> Self { + let values = Value::Array(vector.into_iter().map(|n| n.into()).collect()); + self.queries.push(Query::vector_dot(attribute, values)); + self + } + + pub fn vector_cosine, N: Into>( + mut self, + attribute: S, + vector: Vec, + ) -> Self { + let values = Value::Array(vector.into_iter().map(|n| n.into()).collect()); + self.queries.push(Query::vector_cosine(attribute, values)); + self + } + + pub fn vector_euclidean, N: Into>( + mut self, + attribute: S, + vector: Vec, + ) -> Self { + let values = Value::Array(vector.into_iter().map(|n| n.into()).collect()); + self.queries + .push(Query::vector_euclidean(attribute, values)); + self + } + + pub fn covers, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::covers(attribute, values)); + self + } + + pub fn not_covers, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::not_covers(attribute, values)); + self + } + + pub fn spatial_equals, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries.push(Query::spatial_equals(attribute, values)); + self + } + + pub fn not_spatial_equals, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries + .push(Query::not_spatial_equals(attribute, values)); + self + } + + pub fn page(mut self, page: u32, per_page: u32) -> Self { + self.queries.extend(Query::page(page, per_page)); + self + } +} + +impl Serialize for Builder { + fn serialize(&self, serializer: S) -> Result { + self.build().serialize(serializer) + } +} diff --git a/src/query.rs b/src/query/mod.rs similarity index 67% rename from src/query.rs rename to src/query/mod.rs index a495391..fbfcca8 100644 --- a/src/query.rs +++ b/src/query/mod.rs @@ -3,6 +3,9 @@ use serde::Serialize; use serde_json::Value; +mod builder; +pub use builder::Builder; + /// Query builder for filtering and sorting database queries #[derive(Debug, Clone, Serialize)] pub struct Query { @@ -458,6 +461,302 @@ impl Query { Self::new("elemMatch".to_string(), Some(attribute.into()), values) } + pub fn relationship(attribute: S, queries: I) -> Self + where + S: Into, + I: IntoIterator, + Q: AsRef, + { + let values: Vec = queries + .into_iter() + .filter_map(|query| serde_json::from_str(query.as_ref()).ok()) + .collect(); + Self::new("relationship".to_string(), Some(attribute.into()), values) + } + + pub fn count(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("count", attribute, alias) + } + + pub fn count_distinct(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("countDistinct", attribute, alias) + } + + pub fn sum(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("sum", attribute, alias) + } + + pub fn avg(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("avg", attribute, alias) + } + + pub fn min(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("min", attribute, alias) + } + + pub fn max(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("max", attribute, alias) + } + + pub fn stddev(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("stddev", attribute, alias) + } + + pub fn stddev_pop(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("stddevPop", attribute, alias) + } + + pub fn stddev_samp(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("stddevSamp", attribute, alias) + } + + pub fn variance(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("variance", attribute, alias) + } + + pub fn var_pop(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("varPop", attribute, alias) + } + + pub fn var_samp(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("varSamp", attribute, alias) + } + + pub fn bit_and(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("bitAnd", attribute, alias) + } + + pub fn bit_or(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("bitOr", attribute, alias) + } + + pub fn bit_xor(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("bitXor", attribute, alias) + } + + pub fn group_by(attributes: I) -> Self + where + I: IntoIterator, + S: Into, + { + let values: Vec = attributes + .into_iter() + .map(|s| Value::String(s.into())) + .collect(); + Self::new("groupBy".to_string(), None, values) + } + + pub fn having(queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + let values: Vec = queries + .into_iter() + .filter_map(|query| serde_json::from_str(query.as_ref()).ok()) + .collect(); + Self::new("having".to_string(), None, values) + } + + pub fn distinct() -> Self { + Self::new("distinct".to_string(), None, vec![]) + } + + pub fn on( + left: impl Into, + right: impl Into, + operator: impl Into, + ) -> Self { + Self::new( + "on".to_string(), + None, + vec![ + Value::String(left.into()), + Value::String(operator.into()), + Value::String(right.into()), + ], + ) + } + + pub fn join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("join", table, left, right, operator, alias) + } + + pub fn left_join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("leftJoin", table, left, right, operator, alias) + } + + pub fn right_join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("rightJoin", table, left, right, operator, alias) + } + + pub fn full_outer_join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("fullOuterJoin", table, left, right, operator, alias) + } + + pub fn cross_join(table: impl Into, alias: impl Into) -> Self { + Self::aliased("crossJoin", table, alias) + } + + pub fn join_on(table: impl Into, alias: impl Into, on: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("join", table, alias, on) + } + + pub fn left_join_on(table: impl Into, alias: impl Into, on: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("leftJoin", table, alias, on) + } + + pub fn right_join_on(table: impl Into, alias: impl Into, on: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("rightJoin", table, alias, on) + } + + pub fn full_outer_join_on( + table: impl Into, + alias: impl Into, + on: I, + ) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("fullOuterJoin", table, alias, on) + } + + pub fn covers, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "covers".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn not_covers, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "notCovers".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn spatial_equals, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "spatialEquals".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn not_spatial_equals, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "notSpatialEquals".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn page(page: u32, per_page: u32) -> Vec { + if page < 1 { + panic!("Page must be >= 1, got {}", page); + } + if per_page < 1 { + panic!("Per page must be >= 1, got {}", per_page); + } + vec![Self::limit(per_page), Self::offset((page - 1) * per_page)] + } + + pub fn builder() -> Builder { + Builder::new() + } + + fn aliased(method: &str, attribute: impl Into, alias: impl Into) -> Self { + let alias = alias.into(); + let values = if alias.is_empty() { + vec![] + } else { + vec![Value::String(alias)] + }; + Self::new(method.to_string(), Some(attribute.into()), values) + } + + fn join_query( + method: &str, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + let mut values = vec![ + Value::String(left.into()), + Value::String(operator.into()), + Value::String(right.into()), + ]; + let alias = alias.into(); + if !alias.is_empty() { + values.push(Value::String(alias)); + } + Self::new(method.to_string(), Some(table.into()), values) + } + + fn nested_join( + method: &str, + table: impl Into, + alias: impl Into, + on: I, + ) -> Self + where + I: IntoIterator, + S: AsRef, + { + let mut values = Vec::new(); + let alias = alias.into(); + if !alias.is_empty() { + values.push(Value::String(alias)); + } + for query in on { + if let Ok(parsed) = serde_json::from_str::(query.as_ref()) { + values.push(parsed); + } + } + Self::new(method.to_string(), Some(table.into()), values) + } + /// Convert query to JSON value (matches Go/Python SDK format) pub fn to_value(self) -> Value { let mut obj = serde_json::Map::new(); @@ -1093,4 +1392,278 @@ mod tests { assert_eq!(value["attribute"], "content"); assert_eq!(value["values"][0], "spam keyword"); } + + #[test] + fn test_count_with_alias() { + let query = Query::count("*", "total"); + let value = query.to_value(); + assert_eq!(value["method"], "count"); + assert_eq!(value["attribute"], "*"); + assert_eq!(value["values"][0], "total"); + } + + #[test] + fn test_count_without_alias() { + let query = Query::count("*", ""); + let value = query.to_value(); + assert_eq!(value["method"], "count"); + assert_eq!(value["attribute"], "*"); + assert!(value.get("values").is_none()); + } + + #[test] + fn test_count_distinct() { + let value = Query::count_distinct("year", "uniqueYears").to_value(); + assert_eq!(value["method"], "countDistinct"); + assert_eq!(value["attribute"], "year"); + assert_eq!(value["values"][0], "uniqueYears"); + } + + #[test] + fn test_sum() { + assert_eq!(Query::sum("price", "total").to_value()["method"], "sum"); + } + + #[test] + fn test_avg() { + assert_eq!(Query::avg("price", "avgPrice").to_value()["method"], "avg"); + } + + #[test] + fn test_min() { + assert_eq!(Query::min("price", "lowest").to_value()["method"], "min"); + } + + #[test] + fn test_max() { + assert_eq!(Query::max("price", "highest").to_value()["method"], "max"); + } + + #[test] + fn test_stddev() { + assert_eq!(Query::stddev("price", "sd").to_value()["method"], "stddev"); + } + + #[test] + fn test_stddev_pop() { + assert_eq!( + Query::stddev_pop("price", "sdp").to_value()["method"], + "stddevPop" + ); + } + + #[test] + fn test_stddev_samp() { + assert_eq!( + Query::stddev_samp("price", "sds").to_value()["method"], + "stddevSamp" + ); + } + + #[test] + fn test_variance() { + assert_eq!( + Query::variance("price", "var").to_value()["method"], + "variance" + ); + } + + #[test] + fn test_var_pop() { + assert_eq!(Query::var_pop("price", "vp").to_value()["method"], "varPop"); + } + + #[test] + fn test_var_samp() { + assert_eq!( + Query::var_samp("price", "vs").to_value()["method"], + "varSamp" + ); + } + + #[test] + fn test_bit_and() { + assert_eq!( + Query::bit_and("flags", "band").to_value()["method"], + "bitAnd" + ); + } + + #[test] + fn test_bit_or() { + assert_eq!(Query::bit_or("flags", "bor").to_value()["method"], "bitOr"); + } + + #[test] + fn test_bit_xor() { + assert_eq!( + Query::bit_xor("flags", "bxor").to_value()["method"], + "bitXor" + ); + } + + #[test] + fn test_group_by() { + let query = Query::group_by(vec!["status", "year"]); + let value = query.to_value(); + assert_eq!(value["method"], "groupBy"); + assert_eq!(value["values"][0], "status"); + assert_eq!(value["values"][1], "year"); + } + + #[test] + fn test_having() { + let query = Query::having(vec![Query::greater_than("total", 1).to_string()]); + let value = query.to_value(); + assert_eq!(value["method"], "having"); + assert_eq!(value["values"][0]["method"], "greaterThan"); + assert_eq!(value["values"][0]["attribute"], "total"); + assert_eq!(value["values"][0]["values"][0], 1); + } + + #[test] + fn test_distinct() { + let query = Query::distinct(); + let value = query.to_value(); + assert_eq!(value["method"], "distinct"); + } + + #[test] + fn test_join() { + let query = Query::join("orders", "$id", "customerId", "=", ""); + let value = query.to_value(); + assert_eq!(value["method"], "join"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][0], "$id"); + assert_eq!(value["values"][1], "="); + assert_eq!(value["values"][2], "customerId"); + assert_eq!(value["values"].as_array().unwrap().len(), 3); + } + + #[test] + fn test_left_join_with_alias() { + let query = Query::left_join("orders", "$id", "customerId", "=", "ord"); + let value = query.to_value(); + assert_eq!(value["method"], "leftJoin"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][3], "ord"); + } + + #[test] + fn test_on() { + let query = Query::on("$id", "customerId", "="); + let value = query.to_value(); + assert_eq!(value["method"], "on"); + assert_eq!(value["values"][0], "$id"); + assert_eq!(value["values"][1], "="); + assert_eq!(value["values"][2], "customerId"); + } + + #[test] + fn test_nested_left_join() { + let query = Query::left_join_on( + "orders", + "ord", + [ + Query::on("$id", "customerId", "=").to_string(), + Query::equal("ord.status", "paid").to_string(), + ], + ); + let value = query.to_value(); + assert_eq!(value["method"], "leftJoin"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][0], "ord"); + assert_eq!(value["values"][1]["method"], "on"); + assert_eq!(value["values"][2]["method"], "equal"); + } + + #[test] + fn test_cross_join() { + let query = Query::cross_join("orders", "ord"); + let value = query.to_value(); + assert_eq!(value["method"], "crossJoin"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][0], "ord"); + } + + #[test] + fn test_right_join() { + let value = Query::right_join("orders", "$id", "customerId", "=", "").to_value(); + assert_eq!(value["method"], "rightJoin"); + assert_eq!(value["values"][0], "$id"); + assert_eq!(value["values"][1], "="); + assert_eq!(value["values"][2], "customerId"); + } + + #[test] + fn test_full_outer_join() { + let value = Query::full_outer_join("orders", "$id", "customerId", "=", "").to_value(); + assert_eq!(value["method"], "fullOuterJoin"); + } + + #[test] + fn test_not_covers() { + let value = Query::not_covers( + "location", + Value::Array(vec![Value::from(1), Value::from(2)]), + ) + .to_value(); + assert_eq!(value["method"], "notCovers"); + assert_eq!(value["values"][0][0], 1); + assert_eq!(value["values"][0][1], 2); + } + + #[test] + fn test_spatial_equals() { + let value = Query::spatial_equals( + "location", + Value::Array(vec![Value::from(1), Value::from(2)]), + ) + .to_value(); + assert_eq!(value["method"], "spatialEquals"); + } + + #[test] + fn test_not_spatial_equals() { + let value = Query::not_spatial_equals( + "location", + Value::Array(vec![Value::from(1), Value::from(2)]), + ) + .to_value(); + assert_eq!(value["method"], "notSpatialEquals"); + } + + #[test] + fn test_page() { + let queries = Query::page(2, 10); + assert_eq!(queries.len(), 2); + let limit = queries[0].clone().to_value(); + let offset = queries[1].clone().to_value(); + assert_eq!(limit["method"], "limit"); + assert_eq!(limit["values"][0], 10); + assert_eq!(offset["method"], "offset"); + assert_eq!(offset["values"][0], 10); + } + + #[test] + fn test_builder_build() { + let built = Query::builder() + .equal("status", "published") + .left_join("orders", "$id", "customerId", "=", "ord") + .count("*", "total") + .group_by(vec!["status"]) + .limit(25) + .build(); + + assert_eq!( + built, + vec![ + Query::equal("status", "published").to_string(), + Query::left_join("orders", "$id", "customerId", "=", "ord").to_string(), + Query::count("*", "total").to_string(), + Query::group_by(vec!["status"]).to_string(), + Query::limit(25).to_string(), + ] + ); + } } diff --git a/src/services/account.rs b/src/services/account.rs index 9313048..1db7444 100644 --- a/src/services/account.rs +++ b/src/services/account.rs @@ -105,9 +105,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -117,18 +127,25 @@ impl Account { /// Delete an OAuth2 consent by its unique ID. All token families issued under /// the consent are revoked, and the app must ask for consent again to regain /// access. - pub async fn delete_consent( - &self, - consent_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_consent(&self, consent_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -157,9 +174,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -177,10 +204,30 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -194,16 +241,36 @@ impl Account { &self, consent_id: impl Into, token_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -270,43 +337,27 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/account/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } - /// 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. - pub async fn list_logs( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/account/logs".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - /// Enable or disable MFA on an account. pub async fn update_mfa(&self, mfa: bool) -> crate::error::Result { let mut params = HashMap::new(); @@ -375,6 +426,7 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/mfa/authenticators/{type}" .to_string() @@ -928,6 +980,7 @@ impl Account { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/sessions".to_string(); @@ -958,6 +1011,9 @@ impl Account { /// 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 @@ -1137,9 +1193,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1158,9 +1224,19 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1176,10 +1252,21 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1289,6 +1376,10 @@ impl Account { /// 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). diff --git a/src/services/activities.rs b/src/services/activities.rs index c9017d0..b482235 100644 --- a/src/services/activities.rs +++ b/src/services/activities.rs @@ -55,9 +55,19 @@ impl Activities { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let event_id = event_id.into(); + if event_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"eventId\"", + None, + String::new(), + )); + } + let path = "/activities/events/{eventId}" .to_string() - .replace("{eventId}", &event_id.into().to_string()); + .replace("{eventId}", &event_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/advisor.rs b/src/services/advisor.rs index 084c5f2..ae581e6 100644 --- a/src/services/advisor.rs +++ b/src/services/advisor.rs @@ -61,9 +61,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -76,10 +86,21 @@ impl Advisor { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -107,9 +128,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -126,10 +157,30 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + + let insight_id = insight_id.into(); + if insight_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"insightId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights/{insightId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()) - .replace("{insightId}", &insight_id.into().to_string()); + .replace("{reportId}", &report_id) + .replace("{insightId}", &insight_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/apps.rs b/src/services/apps.rs index 46c3c4b..8ed7d09 100644 --- a/src/services/apps.rs +++ b/src/services/apps.rs @@ -189,9 +189,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -301,9 +309,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -311,18 +327,23 @@ impl Apps { } /// Delete an application by its unique ID. - pub async fn delete( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -351,9 +372,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -372,10 +403,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -389,16 +440,36 @@ impl Apps { &self, app_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -423,10 +494,30 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -453,9 +544,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -474,9 +573,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -493,10 +600,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,16 +635,36 @@ impl Apps { &self, app_id: impl Into, key_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -544,9 +691,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/labels" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -573,9 +730,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -592,9 +759,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -611,10 +788,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -626,16 +823,36 @@ impl Apps { &self, app_id: impl Into, secret_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -654,9 +871,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/team" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/team".to_string().replace("{appId}", &app_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -664,18 +889,25 @@ impl Apps { } /// Revoke all tokens for an application by its unique ID. - pub async fn delete_tokens( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_tokens(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/avatars.rs b/src/services/avatars.rs index 60c40ab..6a529a4 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -236,9 +236,9 @@ impl Avatars { } /// 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, @@ -483,27 +483,6 @@ impl crate::services::Service for Avatars { mod tests { use super::*; - #[tokio::test] - async fn test_update_photo_sends_one_request_whatever_the_chunk_size() { - use wiremock::matchers::{method, path}; - use wiremock::{Mock, MockServer, ResponseTemplate}; - - let server = MockServer::start().await; - Mock::given(method("PUT")) - .and(path("/avatars/photo")) - .respond_with(ResponseTemplate::new(500)) - .mount(&server) - .await; - - let client = Client::new().set_endpoint(server.uri()).set_chunk_size(1); - let file = InputFile::from_bytes(vec![0u8; 10], "photo.png", Some("image/png")); - let _ = Avatars::new(&client).update_photo(file).await; - - let requests = server.received_requests().await.unwrap(); - assert_eq!(requests.len(), 1); - assert!(requests[0].headers.get("content-range").is_none()); - } - #[test] fn test_avatars_creation() { let client = Client::new(); diff --git a/src/services/backups.rs b/src/services/backups.rs index 3379cb7..20fb617 100644 --- a/src/services/backups.rs +++ b/src/services/backups.rs @@ -77,9 +77,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -87,18 +97,25 @@ impl Backups { } /// Delete an existing archive for a project. - pub async fn delete_archive( - &self, - archive_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_archive(&self, archive_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -173,9 +190,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -208,9 +235,19 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -218,18 +255,25 @@ impl Backups { } /// Delete a policy using it's ID. - pub async fn delete_policy( - &self, - policy_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_policy(&self, policy_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -325,9 +369,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/backups/restorations/{restorationId}" .to_string() - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/databases.rs b/src/services/databases.rs index 6d30c67..c9f3774 100644 --- a/src/services/databases.rs +++ b/src/services/databases.rs @@ -134,9 +134,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -178,10 +198,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -221,9 +262,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -248,9 +299,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -263,10 +324,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -298,9 +370,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -348,9 +430,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -368,10 +460,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -413,10 +525,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -433,11 +565,32 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -465,10 +618,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,10 +681,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -550,11 +743,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -584,10 +807,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -617,11 +860,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -651,10 +924,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -684,11 +977,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -718,10 +1041,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -751,11 +1094,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -795,10 +1168,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -837,11 +1230,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -881,10 +1304,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -923,11 +1366,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -967,10 +1440,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1502,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1043,10 +1566,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1076,11 +1619,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1106,10 +1679,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1139,11 +1732,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1178,10 +1801,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1211,11 +1854,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1250,10 +1923,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1283,11 +1976,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1313,10 +2036,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1346,11 +2089,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1376,10 +2149,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1409,11 +2202,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1456,10 +2279,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1487,12 +2330,42 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1529,10 +2402,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1567,11 +2460,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1606,10 +2529,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1639,11 +2582,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1673,10 +2646,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1706,11 +2699,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1747,10 +2770,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1785,11 +2828,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1807,11 +2880,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1828,12 +2931,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1870,10 +3004,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1909,10 +3063,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1939,10 +3113,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1969,10 +3163,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2007,10 +3221,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2040,10 +3274,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2073,11 +3327,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2114,11 +3398,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2153,11 +3467,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2178,12 +3522,43 @@ impl Databases { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2216,13 +3591,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2255,13 +3670,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2289,10 +3744,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2301,7 +3776,9 @@ impl Databases { /// Creates an index on the attributes listed. Your index should include all /// the attributes you will query in a single request. - /// Attributes can be `key`, `fulltext`, and `unique`. + /// Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + /// `trigram` is only available on PostgreSQL and lets `contains`, + /// `startsWith`, and `endsWith` queries on string attributes use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2333,10 +3810,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2354,11 +3851,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2375,12 +3902,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/documents_db.rs b/src/services/documents_db.rs index 6f761f7..ca88c34 100644 --- a/src/services/documents_db.rs +++ b/src/services/documents_db.rs @@ -86,8 +86,8 @@ impl DocumentsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -381,9 +463,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +493,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -444,10 +556,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -464,11 +596,32 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -505,10 +658,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -544,10 +717,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -574,10 +767,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -604,10 +817,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -642,10 +875,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -675,10 +928,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -708,11 +981,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -749,11 +1052,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -788,11 +1121,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -813,12 +1176,43 @@ impl DocumentsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -851,13 +1245,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -890,13 +1324,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -924,10 +1398,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -968,10 +1462,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -989,11 +1503,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1010,12 +1554,43 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1044,9 +1619,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1077,9 +1662,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1096,9 +1691,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1116,9 +1721,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/functions.rs b/src/services/functions.rs index 3dd0131..85f8f06 100644 --- a/src/services/functions.rs +++ b/src/services/functions.rs @@ -224,9 +224,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -260,6 +270,7 @@ impl Functions { runtime_specification: Option<&str>, deployment_retention: Option, interval: Option, + email_enabled: Option, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); @@ -338,13 +349,26 @@ impl Functions { if let Some(value) = interval { params.insert("interval".to_string(), json!(value)); } + if let Some(value) = email_enabled { + params.insert("emailEnabled".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -356,10 +380,21 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -379,9 +414,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployment" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -413,9 +458,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -455,12 +510,30 @@ impl Functions { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -484,9 +557,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/duplicate" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -522,9 +605,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/template" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -551,9 +644,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/vcs" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -570,10 +673,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -589,11 +712,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -620,10 +764,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/download" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -645,10 +809,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/status" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -676,9 +860,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -723,9 +917,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -742,10 +946,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -761,11 +985,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -792,9 +1037,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -822,9 +1077,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -841,10 +1106,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -874,10 +1159,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -893,11 +1198,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/messaging.rs b/src/services/messaging.rs index 71dc9c2..596c87a 100644 --- a/src/services/messaging.rs +++ b/src/services/messaging.rs @@ -222,9 +222,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/email/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -433,9 +443,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/push/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -538,9 +558,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/sms/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -556,9 +586,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -571,10 +611,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -601,9 +652,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}/targets" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -724,9 +785,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/apns/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -860,9 +931,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/fcm/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -969,9 +1050,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/mailgun/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1044,9 +1135,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/msg91/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1137,9 +1238,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/resend/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1230,9 +1341,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/sendgrid/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1339,9 +1460,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/ses/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1478,9 +1609,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/smtp/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1553,9 +1694,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/telesign/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1628,9 +1779,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/textmagic/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1703,9 +1864,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/twilio/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1778,9 +1949,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/vonage/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1796,9 +1977,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1813,10 +2004,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1897,9 +2099,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1935,9 +2147,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1949,10 +2171,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1983,9 +2216,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2006,9 +2249,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2025,10 +2278,30 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2044,11 +2317,32 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/mongo.rs b/src/services/mongo.rs index 9b57b1e..8650fdd 100644 --- a/src/services/mongo.rs +++ b/src/services/mongo.rs @@ -121,8 +121,8 @@ impl Mongo { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mongo { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mongo { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mongo { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -682,9 +909,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -707,9 +944,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -735,9 +982,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -768,9 +1025,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -787,9 +1054,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -806,9 +1083,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -841,9 +1128,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -854,6 +1151,18 @@ impl Mongo { /// backup restoration, provide a backupId. For PITR, provide a targetTime as /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and /// is only available for enterprise databases. + /// + /// By default the backup is replayed over the database it was taken from. Pass + /// `restoreMode` as `clone` to recover it onto a second workload beside this + /// database instead: this database keeps serving its own data while the clone + /// is filled, and the switch happens as soon as the clone is ready, on the + /// endpoint and credentials it already had. Pass `autoPromote` as false to + /// hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + /// to recover onto a separate database with its own endpoint, either one you + /// name with `targetDatabaseId` or one provisioned as a copy of this + /// database's engine, version, specification and replicas. Neither mode is + /// available for a point-in-time recovery or an incremental backup. + #[allow(clippy::too_many_arguments)] pub async fn create_restoration( &self, database_id: impl Into, @@ -861,6 +1170,9 @@ impl Mongo { backup_id: Option<&str>, target_database_id: Option<&str>, target_time: Option<&str>, + restore_mode: Option<&str>, + target_name: Option<&str>, + auto_promote: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { @@ -875,13 +1187,32 @@ impl Mongo { if let Some(value) = target_time { params.insert("targetTime".to_string(), json!(value)); } + if let Some(value) = restore_mode { + params.insert("restoreMode".to_string(), json!(value)); + } + if let Some(value) = target_name { + params.insert("targetName".to_string(), json!(value)); + } + if let Some(value) = auto_promote { + params.insert("autoPromote".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -899,16 +1230,82 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) .await } + /// Switch the database over to the clone a restoration recovered. The database + /// keeps + /// its endpoint and credentials; clients reconnect once. Writes made after the + /// recovery point are discarded, and the side being replaced is retained + /// briefly so + /// the switch can be reversed. + pub async fn promote_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + + let path = "/mongo/{databaseId}/restorations/{restorationId}/promotions" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get real-time health and status information for a dedicated database. /// Returns health status, readiness, uptime, connection info, replica status, /// and volume information. @@ -920,9 +1317,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -942,9 +1349,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/mysql.rs b/src/services/mysql.rs index 434f42b..ddfe81e 100644 --- a/src/services/mysql.rs +++ b/src/services/mysql.rs @@ -121,8 +121,8 @@ impl Mysql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mysql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mysql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mysql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,6 +896,10 @@ impl Mysql { /// without a per-query cloud round-trip. The statement type must be on the /// database's configured allow-list. Use bound parameters for any /// user-supplied values — the API does not interpolate raw strings. + /// Long-running statements (for example CREATE INDEX) can outlive the HTTP + /// request: if the request ends before a result is returned, check the + /// database before retrying, and prefer a direct connection for work that may + /// take minutes. pub async fn create_execution( &self, database_id: impl Into, @@ -688,9 +919,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -719,9 +960,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -744,9 +995,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -772,9 +1033,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -805,9 +1076,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -824,9 +1105,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -843,9 +1134,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -896,9 +1197,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -915,9 +1226,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -950,9 +1271,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -963,6 +1294,18 @@ impl Mysql { /// backup restoration, provide a backupId. For PITR, provide a targetTime as /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and /// is only available for enterprise databases. + /// + /// By default the backup is replayed over the database it was taken from. Pass + /// `restoreMode` as `clone` to recover it onto a second workload beside this + /// database instead: this database keeps serving its own data while the clone + /// is filled, and the switch happens as soon as the clone is ready, on the + /// endpoint and credentials it already had. Pass `autoPromote` as false to + /// hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + /// to recover onto a separate database with its own endpoint, either one you + /// name with `targetDatabaseId` or one provisioned as a copy of this + /// database's engine, version, specification and replicas. Neither mode is + /// available for a point-in-time recovery or an incremental backup. + #[allow(clippy::too_many_arguments)] pub async fn create_restoration( &self, database_id: impl Into, @@ -970,6 +1313,9 @@ impl Mysql { backup_id: Option<&str>, target_database_id: Option<&str>, target_time: Option<&str>, + restore_mode: Option<&str>, + target_name: Option<&str>, + auto_promote: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { @@ -984,13 +1330,32 @@ impl Mysql { if let Some(value) = target_time { params.insert("targetTime".to_string(), json!(value)); } + if let Some(value) = restore_mode { + params.insert("restoreMode".to_string(), json!(value)); + } + if let Some(value) = target_name { + params.insert("targetName".to_string(), json!(value)); + } + if let Some(value) = auto_promote { + params.insert("autoPromote".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1008,16 +1373,82 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) .await } + /// Switch the database over to the clone a restoration recovered. The database + /// keeps + /// its endpoint and credentials; clients reconnect once. Writes made after the + /// recovery point are discarded, and the side being replaced is retained + /// briefly so + /// the switch can be reversed. + pub async fn promote_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + + let path = "/mysql/{databaseId}/restorations/{restorationId}/promotions" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get real-time health and status information for a dedicated database. /// Returns health status, readiness, uptime, connection info, replica status, /// and volume information. @@ -1029,9 +1460,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1051,9 +1492,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/oauth2.rs b/src/services/oauth2.rs index 834934a..9691f1f 100644 --- a/src/services/oauth2.rs +++ b/src/services/oauth2.rs @@ -81,7 +81,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -120,7 +120,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -165,7 +168,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -204,7 +207,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -238,7 +244,7 @@ impl Oauth2 { client_id: Option<&str>, scope: Option<&str>, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -252,7 +258,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -318,6 +327,16 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let grant_id = grant_id.into(); + if grant_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"grantId\"", + None, + String::new(), + )); + } + let path = "/oauth2/{project_id}/grants/{grant_id}" .to_string() .replace( @@ -329,7 +348,7 @@ impl Oauth2 { .cloned() .unwrap_or_default(), ) - .replace("{grant_id}", &grant_id.into().to_string()); + .replace("{grant_id}", &grant_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -430,7 +449,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -462,7 +481,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -603,7 +625,7 @@ impl Oauth2 { client_secret: Option<&str>, code_verifier: Option<&str>, redirect_uri: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -630,7 +652,10 @@ impl Oauth2 { params.insert("redirect_uri".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); diff --git a/src/services/organization.rs b/src/services/organization.rs index 176b0f5..a574ade 100644 --- a/src/services/organization.rs +++ b/src/services/organization.rs @@ -60,6 +60,7 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/organization".to_string(); @@ -129,9 +130,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -155,9 +166,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -170,130 +191,25 @@ impl Organization { pub async fn delete_installation( &self, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}" - .to_string() - .replace("{installationId}", &installation_id.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a list of all API keys from the current organization. - pub async fn list_keys( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Create a new organization API key. - pub async fn create_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("keyId".to_string(), json!(key_id.into())); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::POST, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a key by its unique ID. This endpoint returns details about a specific - /// API key in your organization including its scopes. - pub async fn get_key( - &self, - key_id: impl Into, - ) -> crate::error::Result { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Update a key by its unique ID. Use this endpoint to update the name, - /// scopes, or expiration time of an API key. - pub async fn update_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Delete a key by its unique ID. Once deleted, the key can no longer be used - /// to authenticate API calls. - pub async fn delete_key(&self, key_id: impl Into) -> crate::error::Result<()> { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" + let path = "/organization/installations/{installationId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -382,9 +298,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -406,9 +332,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -425,10 +361,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -496,13 +443,25 @@ impl Organization { project_id: impl Into, ) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -518,9 +477,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } + let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -532,10 +501,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/postgresql.rs b/src/services/postgresql.rs index e736abe..94d766a 100644 --- a/src/services/postgresql.rs +++ b/src/services/postgresql.rs @@ -121,8 +121,8 @@ impl Postgresql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Postgresql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Postgresql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Postgresql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,6 +896,10 @@ impl Postgresql { /// without a per-query cloud round-trip. The statement type must be on the /// database's configured allow-list. Use bound parameters for any /// user-supplied values — the API does not interpolate raw strings. + /// Long-running statements (for example CREATE INDEX) can outlive the HTTP + /// request: if the request ends before a result is returned, check the + /// database before retrying, and prefer a direct connection for work that may + /// take minutes. pub async fn create_execution( &self, database_id: impl Into, @@ -688,9 +919,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -706,9 +947,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -728,9 +979,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -749,10 +1010,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let extension_name = extension_name.into(); + if extension_name.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"extensionName\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions/{extensionName}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{extensionName}", &extension_name.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{extensionName}", &extension_name); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -781,9 +1062,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -806,9 +1097,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -834,9 +1135,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -867,9 +1178,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -886,9 +1207,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -905,9 +1236,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -958,9 +1299,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -977,9 +1328,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1012,9 +1373,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1025,6 +1396,18 @@ impl Postgresql { /// backup restoration, provide a backupId. For PITR, provide a targetTime as /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and /// is only available for enterprise databases. + /// + /// By default the backup is replayed over the database it was taken from. Pass + /// `restoreMode` as `clone` to recover it onto a second workload beside this + /// database instead: this database keeps serving its own data while the clone + /// is filled, and the switch happens as soon as the clone is ready, on the + /// endpoint and credentials it already had. Pass `autoPromote` as false to + /// hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + /// to recover onto a separate database with its own endpoint, either one you + /// name with `targetDatabaseId` or one provisioned as a copy of this + /// database's engine, version, specification and replicas. Neither mode is + /// available for a point-in-time recovery or an incremental backup. + #[allow(clippy::too_many_arguments)] pub async fn create_restoration( &self, database_id: impl Into, @@ -1032,6 +1415,9 @@ impl Postgresql { backup_id: Option<&str>, target_database_id: Option<&str>, target_time: Option<&str>, + restore_mode: Option<&str>, + target_name: Option<&str>, + auto_promote: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { @@ -1046,13 +1432,32 @@ impl Postgresql { if let Some(value) = target_time { params.insert("targetTime".to_string(), json!(value)); } + if let Some(value) = restore_mode { + params.insert("restoreMode".to_string(), json!(value)); + } + if let Some(value) = target_name { + params.insert("targetName".to_string(), json!(value)); + } + if let Some(value) = auto_promote { + params.insert("autoPromote".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1070,16 +1475,82 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) .await } + /// Switch the database over to the clone a restoration recovered. The database + /// keeps + /// its endpoint and credentials; clients reconnect once. Writes made after the + /// recovery point are discarded, and the side being replaced is retained + /// briefly so + /// the switch can be reversed. + pub async fn promote_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + + let path = "/postgresql/{databaseId}/restorations/{restorationId}/promotions" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get real-time health and status information for a dedicated database. /// Returns health status, readiness, uptime, connection info, replica status, /// and volume information. @@ -1091,9 +1562,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1113,9 +1594,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/presences.rs b/src/services/presences.rs index 2954c14..6b777c6 100644 --- a/src/services/presences.rs +++ b/src/services/presences.rs @@ -64,9 +64,19 @@ impl Presences { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -102,9 +112,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -148,9 +168,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -162,10 +192,21 @@ impl Presences { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/project.rs b/src/services/project.rs index 43c2af2..24f9252 100644 --- a/src/services/project.rs +++ b/src/services/project.rs @@ -27,11 +27,13 @@ impl Project { /// Get a project. pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -40,6 +42,7 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); @@ -266,9 +269,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -294,9 +307,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -309,10 +332,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -402,9 +436,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -424,9 +468,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -439,10 +493,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1253,8 +1318,8 @@ impl Project { &self, client_id: Option<&str>, client_secret: Option<&str>, - prompt: Option>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1263,12 +1328,12 @@ impl Project { if let Some(value) = client_secret { params.insert("clientSecret".to_string(), json!(value)); } - if let Some(value) = prompt { - params.insert("prompt".to_string(), json!(value)); - } if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } + if let Some(value) = prompt { + params.insert("prompt".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); @@ -2147,7 +2212,7 @@ impl Project { } /// 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. pub async fn update_android_platform( &self, platform_id: impl Into, @@ -2168,9 +2233,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/android/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2222,9 +2297,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/apple/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2270,9 +2355,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/linux/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2318,9 +2413,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/web/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2372,9 +2477,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/windows/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2391,9 +2506,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2409,10 +2534,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -3027,6 +3163,7 @@ impl Project { ); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project/smtp/tests".to_string(); @@ -3197,9 +3334,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -3228,9 +3375,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -3245,10 +3402,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/proxy.rs b/src/services/proxy.rs index 2507b73..46dcbbf 100644 --- a/src/services/proxy.rs +++ b/src/services/proxy.rs @@ -29,6 +29,8 @@ impl Proxy { /// /// 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. pub async fn create_invalidation( &self, domain: impl Into, @@ -184,6 +186,31 @@ impl Proxy { .await } + /// Create an SMTP ingress rule that asynchronously executes an Appwrite + /// Function for incoming email. + pub async fn create_smtp_rule( + &self, + domain: impl Into, + function_id: impl Into, + branch: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("domain".to_string(), json!(domain.into())); + params.insert("functionId".to_string(), json!(function_id.into())); + if let Some(value) = branch { + params.insert("branch".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/proxy/rules/smtp".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get a proxy rule by its unique ID. pub async fn get_rule( &self, @@ -193,9 +220,19 @@ impl Proxy { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -207,10 +244,21 @@ impl Proxy { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -230,9 +278,19 @@ impl Proxy { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}/status" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/sites.rs b/src/services/sites.rs index 150a50d..99a6e87 100644 --- a/src/services/sites.rs +++ b/src/services/sites.rs @@ -217,9 +217,17 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +339,17 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -345,10 +361,19 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -368,9 +393,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployment" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -402,9 +437,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -443,12 +488,30 @@ impl Sites { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -468,9 +531,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/duplicate" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -506,9 +579,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/template" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -535,9 +618,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/vcs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -554,10 +647,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -573,11 +686,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -604,10 +738,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/download" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -629,10 +783,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/status" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -660,9 +834,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -679,10 +863,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -694,16 +898,36 @@ impl Sites { &self, site_id: impl Into, log_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -730,9 +954,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -760,9 +994,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -779,10 +1023,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -812,10 +1076,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -831,11 +1115,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/storage.rs b/src/services/storage.rs index 4736eaf..2f49674 100644 --- a/src/services/storage.rs +++ b/src/services/storage.rs @@ -127,9 +127,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -191,9 +201,19 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -205,10 +225,21 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -240,9 +271,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -293,12 +334,23 @@ impl Storage { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client - .file_upload( + .upload( + Method::POST, &path, Some(api_headers), params, @@ -320,10 +372,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -353,10 +425,30 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -373,11 +465,32 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -400,10 +513,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/download" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -473,10 +606,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/preview" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/view" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/tables_db.rs b/src/services/tables_db.rs index a9f0f21..0807051 100644 --- a/src/services/tables_db.rs +++ b/src/services/tables_db.rs @@ -92,8 +92,8 @@ impl TablesDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -163,9 +163,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -190,9 +200,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -207,10 +227,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -231,9 +262,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -250,9 +291,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -289,9 +340,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -304,10 +365,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -336,9 +408,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -355,9 +437,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -365,8 +457,13 @@ impl TablesDB { } /// Start migrating a serverless TablesDB database onto a dedicated MySQL - /// compute. Data is copied to the target while the source stays live, with a - /// brief read-only window during cutover. + /// compute. Data is copied to the target while the source stays live. Reads + /// continue throughout. Row writes are held for up to a few seconds while + /// routing switches to the dedicated compute; a write the switch has not + /// absorbed within that hold is refused with `database_migration_cutover` and + /// can be retried. Schema changes (tables, columns, indexes) are refused from + /// creation until the cutover completes, and resume once the migration is + /// `soaking`. pub async fn create_migration( &self, database_id: impl Into, @@ -382,9 +479,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +508,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -417,16 +544,36 @@ impl TablesDB { &self, database_id: impl Into, migration_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -436,9 +583,12 @@ impl TablesDB { /// Cut a verified TablesDB migration over to its dedicated compute. Only /// applies to a migration created with `autoCutover` disabled, which waits at /// `ready_to_cutover` until this is called. The routing flip happens shortly - /// after this returns, with a brief read-only window. One call buys one - /// attempt: a cutover that fails a check returns the migration to `verifying` - /// and parks it again, so call this once more to retry. + /// after this returns. Reads are unaffected; row writes are held for up to a + /// few seconds while it lands, and a write the flip has not absorbed within + /// that hold is refused with `database_migration_cutover` and can be retried. + /// One call buys one attempt: a cutover that fails a check returns the + /// migration to `verifying` and parks it again, so call this once more to + /// retry. pub async fn create_cutover( &self, database_id: impl Into, @@ -449,10 +599,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}/cutovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -483,9 +653,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -502,9 +682,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -522,9 +712,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -556,9 +756,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +816,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -626,10 +846,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -671,10 +911,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -691,11 +951,32 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -723,10 +1004,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -766,10 +1067,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -808,11 +1129,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -842,10 +1193,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -875,11 +1246,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -909,10 +1310,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -942,11 +1363,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -976,10 +1427,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1480,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1053,10 +1554,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1095,11 +1616,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1139,10 +1690,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1181,11 +1752,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1225,10 +1826,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1267,11 +1888,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1301,10 +1952,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1334,11 +2005,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1364,10 +2065,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1397,11 +2118,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1436,10 +2187,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1469,11 +2240,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1508,10 +2309,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1541,11 +2362,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1571,10 +2422,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1604,11 +2475,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1634,10 +2535,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1667,11 +2588,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1711,16 +2662,98 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) .await } + /// Update relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + pub async fn update_relationship_column( + &self, + database_id: impl Into, + table_id: impl Into, + key: impl Into, + on_delete: Option, + new_key: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = on_delete { + params.insert("onDelete".to_string(), json!(value)); + } + if let Some(value) = new_key { + params.insert("newKey".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Create a string column. #[allow(clippy::too_many_arguments)] pub async fn create_string_column( @@ -1751,10 +2784,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1789,11 +2842,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1828,10 +2911,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1861,11 +2964,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1895,10 +3028,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1928,11 +3081,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1969,10 +3152,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2007,11 +3210,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2029,11 +3262,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2050,47 +3313,46 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" - .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } - /// Update relationship column. [Learn more about relationship - /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - pub async fn update_relationship_column( - &self, - database_id: impl Into, - table_id: impl Into, - key: impl Into, - on_delete: Option, - new_key: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = on_delete { - params.insert("onDelete".to_string(), json!(value)); + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); } - if let Some(value) = new_key { - params.insert("newKey".to_string(), json!(value)); + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship" + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client - .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } @@ -2115,10 +3377,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2127,7 +3409,9 @@ impl TablesDB { /// Creates an index on the columns listed. Your index should include all the /// columns you will query in a single request. - /// Type can be `key`, `fulltext`, or `unique`. + /// Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + /// is only available on PostgreSQL and lets `contains`, `startsWith`, and + /// `endsWith` queries on string columns use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2159,10 +3443,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2180,11 +3484,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2201,12 +3535,43 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2243,10 +3608,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2282,10 +3667,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2312,10 +3717,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2342,10 +3767,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2379,10 +3824,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2412,10 +3877,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2445,11 +3930,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2486,11 +4001,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2525,11 +4070,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2550,12 +4125,43 @@ impl TablesDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2588,12 +4194,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2626,12 +4272,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/teams.rs b/src/services/teams.rs index 5f55c5b..68d6978 100644 --- a/src/services/teams.rs +++ b/src/services/teams.rs @@ -93,9 +93,17 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -114,9 +122,17 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -129,10 +145,19 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -159,9 +184,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -187,9 +222,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -207,10 +252,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -235,10 +300,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -252,16 +337,36 @@ impl Teams { &self, team_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -294,9 +399,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -362,9 +477,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -383,10 +508,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -411,10 +556,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -432,11 +597,32 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -463,10 +649,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}/status" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -484,9 +690,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -507,9 +723,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) diff --git a/src/services/tokens.rs b/src/services/tokens.rs index 43b9063..d58c5cb 100644 --- a/src/services/tokens.rs +++ b/src/services/tokens.rs @@ -46,10 +46,30 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -72,10 +92,30 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -91,9 +131,19 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -115,9 +165,19 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -129,10 +189,21 @@ impl Tokens { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/users.rs b/src/services/users.rs index 7cd8e38..73b7d8b 100644 --- a/src/services/users.rs +++ b/src/services/users.rs @@ -184,10 +184,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/users/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -377,9 +388,17 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -396,10 +415,19 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -418,9 +446,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/email" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -431,7 +469,10 @@ impl Users { /// 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. pub async fn update_impersonator( &self, user_id: impl Into, @@ -443,9 +484,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/impersonator" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -472,9 +523,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/jwts" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -504,41 +565,22 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/labels" - .to_string() - .replace("{userId}", &user_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Get the user activity logs list by its unique ID. - pub async fn list_logs( - &self, - user_id: impl Into, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/logs" + let path = "/users/{userId}/labels" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) + .call(Method::PUT, &path, Some(api_headers), Some(params)) .await } @@ -566,9 +608,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/memberships" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -587,9 +639,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -605,10 +667,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/mfa/authenticators/{type}" .to_string() - .replace("{userId}", &user_id.into().to_string()) + .replace("{userId}", &user_id) .replace("{type}", &r#type.to_string()); self.client @@ -627,10 +700,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let challenge_id = challenge_id.into(); + if challenge_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"challengeId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/challenges/{challengeId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{challengeId}", &challenge_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{challengeId}", &challenge_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -646,9 +739,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/factors" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -667,9 +770,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -689,9 +802,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -711,9 +834,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -732,9 +865,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/name" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -917,9 +1060,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/password" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -938,9 +1091,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -956,9 +1119,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -979,9 +1152,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1001,9 +1184,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1025,9 +1218,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1039,10 +1242,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1058,11 +1272,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions/{sessionId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1082,9 +1317,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/status" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1111,9 +1356,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1144,9 +1399,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1163,10 +1428,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1196,10 +1481,30 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1215,11 +1520,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1247,9 +1573,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/tokens" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1268,9 +1604,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1289,9 +1635,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/vectors_db.rs b/src/services/vectors_db.rs index be3894b..a89bf38 100644 --- a/src/services/vectors_db.rs +++ b/src/services/vectors_db.rs @@ -86,8 +86,8 @@ impl VectorsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -375,9 +457,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -395,10 +487,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -438,10 +550,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -458,11 +590,32 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -538,10 +711,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -568,10 +761,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -598,10 +811,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -636,10 +869,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,10 +922,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -712,10 +985,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/query" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -745,11 +1038,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -786,11 +1109,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -825,11 +1178,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -850,12 +1233,43 @@ impl VectorsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -883,10 +1297,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -927,10 +1361,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -948,11 +1402,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -969,12 +1453,43 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1003,9 +1518,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1036,9 +1561,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1055,9 +1590,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1075,9 +1620,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/webhooks.rs b/src/services/webhooks.rs index 0e3e171..c53feda 100644 --- a/src/services/webhooks.rs +++ b/src/services/webhooks.rs @@ -112,9 +112,19 @@ impl Webhooks { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -176,10 +196,21 @@ impl Webhooks { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}/secret" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/topic.rs b/src/topic.rs new file mode 100644 index 0000000..30c26fc --- /dev/null +++ b/src/topic.rs @@ -0,0 +1,158 @@ +//! Topic builder for Appwrite Push, level by level. +//! +//! ``` +//! use appwrite::topic; +//! +//! # fn main() -> Result<(), topic::TopicError> { +//! assert_eq!(topic::path(&["user", "123", "notification"])?.to_string(), "user/123/notification"); +//! assert_eq!(topic::path(&["org", "42"])?.path(&["logs"])?.to_string(), "org/42/logs"); +//! # Ok(()) +//! # } +//! ``` + +use std::fmt; + +/// Error returned by [`path`] and [`Topic::path`] for invalid levels. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct TopicError { + message: String, +} + +impl TopicError { + fn new(message: impl Into) -> Self { + Self { + message: message.into(), + } + } + + /// The error message + pub fn message(&self) -> &str { + &self.message + } +} + +impl fmt::Display for TopicError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.message) + } +} + +impl std::error::Error for TopicError {} + +/// A topic being built. Start one with [`path`]. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Topic { + levels: Vec, +} + +/// Start a topic with the given levels, e.g. `topic::path(&["user", user_id])`. +pub fn path>(levels: &[S]) -> Result { + Ok(Topic { + levels: levels_of(levels)?, + }) +} + +impl Topic { + /// Append the given levels. + pub fn path>(mut self, levels: &[S]) -> Result { + self.levels.extend(levels_of(levels)?); + Ok(self) + } +} + +impl fmt::Display for Topic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.levels.join("/")) + } +} + +/// Validate the levels passed to `path()`: a non-empty list of non-empty strings, none holding +/// the level separator `/` or the MQTT wildcards `+` and `#`. +fn levels_of>(levels: &[S]) -> Result, TopicError> { + if levels.is_empty() { + return Err(TopicError::new("path() needs at least one level")); + } + levels + .iter() + .enumerate() + .map(|(index, level)| { + let level = level.as_ref(); + if level.is_empty() { + return Err(TopicError::new(format!("empty level at index {}", index))); + } + if level.contains('/') { + let parts = level + .split('/') + .map(|part| format!("'{}'", part)) + .collect::>() + .join(", "); + return Err(TopicError::new(format!( + "\"{}\" contains \"/\", split it: path([{}])", + level, parts + ))); + } + if level.contains('+') { + return Err(TopicError::new(format!( + "\"{}\" contains \"+\", not allowed in a topic", + level + ))); + } + if level.contains('#') { + return Err(TopicError::new(format!( + "\"{}\" contains \"#\", not allowed in a topic", + level + ))); + } + if level.contains('\0') { + return Err(TopicError::new(format!( + "level at index {} contains a NUL character", + index + ))); + } + Ok(level.to_string()) + }) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_paths() { + assert_eq!( + path(&["user", "123", "notification"]).unwrap().to_string(), + "user/123/notification" + ); + assert_eq!( + path(&["org", "42", "user", "123"]) + .unwrap() + .path(&["notification"]) + .unwrap() + .to_string(), + "org/42/user/123/notification" + ); + assert_eq!( + path(&[String::from("user"), String::from("123")]) + .unwrap() + .to_string(), + "user/123" + ); + } + + #[test] + fn test_errors() { + let invalid: [&[&str]; 7] = [ + &[], + &["user", ""], + &["user/123"], + &["user", "+"], + &["user", "a+b"], + &["user", "#"], + &["user", "a#b"], + ]; + for levels in invalid { + assert!(path(levels).is_err(), "{:?}", levels); + } + } +} diff --git a/tests/tests.rs b/tests/tests.rs index 2821bc3..afdc35f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,11 +1,13 @@ use appwrite::{ Client, + enums::PresetQuality, id::ID, input_file::InputFile, operator::{self, Condition}, permission::Permission, query::Query, role::Role, + topic, services::*, }; use serde_json::json; @@ -112,12 +114,50 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re Err(e) => eprintln!("general.redirected => error {}", e), } + for (id, plain) in [("", "0"), ("0", "")] { + let error = general.validate_path(plain, Some(id)).await.unwrap_err(); + assert_eq!(error.code, 0); + println!("{}", error.message); + } + println!("{}", general.validate_path("0", Some("0")).await?.result); + println!("{}", general.validate_path("0", None).await?.result); + + let zone: String = Plaintext::new(&client).get_zone().await?; + println!("{}", zone); + println!("{}", general.get_mixed().await?.result); + let plaintext = Plaintext::new(&client); + let records = "www 3600 IN A 192.0.2.1"; + println!("{}", plaintext.import_zone(records, None).await?); + let zone_file = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", plaintext.import_zone(records, Some(zone_file)).await?); + + let message = "conversation without a required file"; + println!("{}", general.optional_upload(message, None, None).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), None).await?.result); + println!("{}", general.optional_upload(message, None, Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + test_general_upload(client, string_in_array).await?; test_large_upload(client, string_in_array).await?; + // A PUT upload has no chunked form, so it must go in one request even with tiny chunks. + let small_chunks = client.set_chunk_size(1024); + let profile = General::new(&small_chunks).upload_generic(InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?).await?; + println!("{}", profile.prefs().get::("result").unwrap_or_default()); // Extended General Responses test_general_download(client).await?; + let preset = general.get_preset(None).await?; + println!("preset: name={}, count={}, enabled={}", preset.name, preset.count, preset.enabled); + for item in general.list_presets().await?.presets { + println!("preset: name={}, count={}, enabled={}", item.name, item.count, item.enabled); + } + println!("empty presets: {}", general.list_empty_presets().await?.presets.len()); + println!("preset verified: {}", preset.verified.map_or("null".to_string(), |verified| verified.to_string())); + println!("preset quality default: {}", PresetQuality::default()); + // Exception Responses match general.error400().await { Ok(_) => {}, @@ -145,16 +185,17 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re println!("Invalid endpoint URL: htp://cloud.appwrite.io/v1"); - let _ = general.empty().await; + let (): () = general.empty().await?; // Test Queries - test_queries(); + test_queries(client).await?; // Test Permission Helpers test_permission_helpers(); // Test Id Helpers test_id_helpers(); + test_topic_helpers(); // Test Operator Helpers test_operator_helpers(); @@ -218,7 +259,7 @@ async fn test_large_upload(client: &Client, string_in_array: &[String]) -> Resul Ok(()) } -fn test_queries() { +async fn test_queries(client: &Client) -> Result<(), Box> { println!("{}", Query::equal("released", true)); println!("{}", Query::equal("title", vec!["Spiderman", "Dr. Strange"])); println!("{}", Query::not_equal("title", "Spiderman")); @@ -293,6 +334,50 @@ fn test_queries() { Query::equal("name", "Alice").to_string(), Query::greater_than("age", 18).to_string(), ])); + println!("{}", Query::relationship("comments", vec![ + Query::equal("approved", true).to_string(), + Query::limit(2).to_string(), + ])); + let general = General::new(client); + let mut queries: Vec = vec![ + Query::count("*", "total").to_string(), + Query::join("orders", "$id", "customerId", "=", "").to_string(), + Query::group_by(vec!["status"]).to_string(), + Query::distinct().to_string(), + Query::covers("location", json!([1, 2])).to_string(), + Query::count_distinct("year", "uniqueYears").to_string(), + Query::sum("price", "total").to_string(), + Query::avg("price", "avgPrice").to_string(), + Query::min("price", "lowest").to_string(), + Query::max("price", "highest").to_string(), + Query::stddev("price", "sd").to_string(), + Query::stddev_pop("price", "sdp").to_string(), + Query::stddev_samp("price", "sds").to_string(), + Query::variance("price", "var").to_string(), + Query::var_pop("price", "vp").to_string(), + Query::var_samp("price", "vs").to_string(), + Query::bit_and("flags", "band").to_string(), + Query::bit_or("flags", "bor").to_string(), + Query::bit_xor("flags", "bxor").to_string(), + Query::having(vec![Query::greater_than("total", 1).to_string()]).to_string(), + Query::left_join("orders", "$id", "customerId", "=", "ord").to_string(), + Query::right_join("orders", "$id", "customerId", "=", "").to_string(), + Query::full_outer_join("orders", "$id", "customerId", "=", "").to_string(), + Query::cross_join("orders", "ord").to_string(), + Query::on("$id", "customerId", "=").to_string(), + Query::left_join_on("orders", "ord", vec![ + Query::on("$id", "customerId", "=").to_string(), + Query::equal("ord.status", "paid").to_string(), + ]).to_string(), + Query::not_covers("location", json!([1, 2])).to_string(), + Query::spatial_equals("location", json!([1, 2])).to_string(), + Query::not_spatial_equals("location", json!([1, 2])).to_string(), + ]; + queries.extend(Query::page(2, 10).iter().map(|query| query.to_string())); + queries.extend(Query::builder().limit(1).build()); + println!("{}", general.list_rows(Some(queries)).await?.result); + + Ok(()) } fn test_permission_helpers() { @@ -313,6 +398,25 @@ fn test_id_helpers() { println!("{}", ID::custom("custom_id")); } +fn test_topic_helpers() { + println!("{}", topic::path(&["user", "123", "notification"]).unwrap()); + println!("{}", topic::path(&["org", "42", "user", "123"]).unwrap().path(&["notification"]).unwrap()); + let cases: Vec<(&str, Vec<&str>)> = vec![ + ("empty path", vec![]), + ("empty level", vec!["user", ""]), + ("slash", vec!["user/123"]), + ("plus", vec!["user", "a+b"]), + ("hash", vec!["user", "#"]), + ("nul", vec!["user", "a\0b"]), + ]; + for (name, levels) in cases { + match topic::path(&levels) { + Ok(_) => println!("Topic {}:failed", name), + Err(_) => println!("Topic {}:passed", name), + } + } +} + fn test_operator_helpers() { println!("{}", operator::increment()); println!("{}", operator::increment_with_max(5, 100)); From e6a29eaf1671db9194eb4d6425366dcadf18101d Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 15 Oct 2026 12:53:10 +0100 Subject: [PATCH 4/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 342 ++- Cargo.toml | 2 +- README.md | 6 +- docs/examples/account/delete-consent-token.md | 4 +- docs/examples/account/delete-consent.md | 4 +- docs/examples/account/list-logs.md | 23 - docs/examples/apps/delete-installation.md | 4 +- docs/examples/apps/delete-key.md | 4 +- docs/examples/apps/delete-secret.md | 4 +- docs/examples/apps/delete-tokens.md | 4 +- docs/examples/apps/delete.md | 4 +- docs/examples/backups/delete-archive.md | 4 +- docs/examples/backups/delete-policy.md | 4 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 2 +- docs/examples/documentsdb/create-documents.md | 2 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 2 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/functions/update.md | 3 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/create-restoration.md | 5 +- docs/examples/mongo/delete-backup-policy.md | 4 +- docs/examples/mongo/delete-backup.md | 4 +- docs/examples/mongo/delete.md | 4 +- .../promote-restoration.md} | 9 +- docs/examples/mysql/create-restoration.md | 5 +- docs/examples/mysql/delete-backup-policy.md | 4 +- docs/examples/mysql/delete-backup.md | 4 +- docs/examples/mysql/delete.md | 4 +- .../promote-restoration.md} | 11 +- docs/examples/oauth2/approve.md | 2 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 2 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 2 +- docs/examples/oauth2/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 25 - .../organization/delete-installation.md | 4 +- docs/examples/organization/update-key.md | 25 - .../examples/postgresql/create-restoration.md | 5 +- .../postgresql/delete-backup-policy.md | 4 +- docs/examples/postgresql/delete-backup.md | 4 +- docs/examples/postgresql/delete.md | 4 +- .../promote-restoration.md} | 10 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- .../create-smtp-rule.md} | 12 +- docs/examples/sites/delete-log.md | 4 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 2 +- docs/examples/tablesdb/delete-migration.md | 4 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 2 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/delete-installation.md | 4 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 2 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 2 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 2 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- src/client.rs | 273 ++- src/enums/billing_plan_group.rs | 5 +- src/enums/execution_method.rs | 2 +- src/enums/execution_trigger.rs | 3 + src/enums/image_gravity.rs | 6 +- src/enums/mod.rs | 4 +- src/enums/organization_key_scopes.rs | 72 - src/enums/proxy_rule_protocol.rs | 26 + src/lib.rs | 5 +- src/models/activity_event.rs | 145 ++ src/models/activity_event_list.rs | 10 + src/models/additional_resource.rs | 30 + src/models/algo_argon2.rs | 20 + src/models/algo_bcrypt.rs | 5 + src/models/algo_md5.rs | 5 + src/models/algo_phpass.rs | 5 + src/models/algo_scrypt.rs | 25 + src/models/algo_scrypt_modified.rs | 20 + src/models/algo_sha.rs | 5 + src/models/app.rs | 130 + src/models/app_installation.rs | 45 + src/models/app_installation_list.rs | 10 + src/models/app_key.rs | 40 + src/models/app_key_list.rs | 10 + src/models/app_scope.rs | 25 + src/models/app_scope_list.rs | 10 + src/models/app_secret.rs | 40 + src/models/app_secret_list.rs | 10 + src/models/app_secret_plaintext.rs | 40 + src/models/apps_list.rs | 10 + src/models/attribute_bigint.rs | 30 + src/models/attribute_boolean.rs | 30 + src/models/attribute_datetime.rs | 30 + src/models/attribute_email.rs | 35 + src/models/attribute_enum.rs | 40 + src/models/attribute_float.rs | 30 + src/models/attribute_integer.rs | 30 + src/models/attribute_ip.rs | 35 + src/models/attribute_line.rs | 30 + src/models/attribute_list.rs | 10 + src/models/attribute_longtext.rs | 30 + src/models/attribute_mediumtext.rs | 30 + src/models/attribute_object.rs | 30 + src/models/attribute_point.rs | 30 + src/models/attribute_polygon.rs | 30 + src/models/attribute_relationship.rs | 55 + src/models/attribute_string.rs | 35 + src/models/attribute_text.rs | 30 + src/models/attribute_url.rs | 35 + src/models/attribute_varchar.rs | 35 + src/models/attribute_vector.rs | 35 + src/models/backup_archive.rs | 72 +- src/models/backup_archive_list.rs | 10 + src/models/backup_policy.rs | 50 + src/models/backup_policy_list.rs | 10 + src/models/backup_restoration.rs | 72 +- src/models/backup_restoration_list.rs | 10 + src/models/billing_plan.rs | 335 ++- src/models/billing_plan_addon_details.rs | 35 + src/models/billing_plan_supported_addons.rs | 15 + src/models/block.rs | 80 +- src/models/bucket.rs | 70 + src/models/bucket_list.rs | 10 + src/models/collection.rs | 60 + src/models/collection_list.rs | 10 + src/models/column_bigint.rs | 30 + src/models/column_boolean.rs | 30 + src/models/column_datetime.rs | 30 + src/models/column_email.rs | 35 + src/models/column_enum.rs | 40 + src/models/column_float.rs | 30 + src/models/column_index.rs | 45 + src/models/column_index_list.rs | 10 + src/models/column_integer.rs | 30 + src/models/column_ip.rs | 35 + src/models/column_line.rs | 30 + src/models/column_list.rs | 10 + src/models/column_longtext.rs | 30 + src/models/column_mediumtext.rs | 30 + src/models/column_point.rs | 30 + src/models/column_polygon.rs | 30 + src/models/column_relationship.rs | 55 + src/models/column_string.rs | 35 + src/models/column_text.rs | 30 + src/models/column_url.rs | 35 + src/models/column_varchar.rs | 35 + src/models/continent.rs | 10 + src/models/continent_list.rs | 10 + src/models/country.rs | 10 + src/models/country_list.rs | 10 + src/models/currency.rs | 35 + src/models/currency_list.rs | 10 + src/models/database.rs | 35 +- src/models/database_list.rs | 10 + src/models/database_migration.rs | 85 + src/models/database_migration_list.rs | 10 + src/models/database_status.rs | 74 +- src/models/database_status_connections.rs | 10 + src/models/database_status_replica.rs | 15 + src/models/database_status_volume.rs | 20 + src/models/dedicated_database.rs | 316 ++- src/models/dedicated_database_backup.rs | 60 + src/models/dedicated_database_backup_list.rs | 10 + .../dedicated_database_backup_storage.rs | 25 + src/models/dedicated_database_branch.rs | 69 +- src/models/dedicated_database_branch_list.rs | 10 + src/models/dedicated_database_execution.rs | 30 + .../dedicated_database_execution_column.rs | 10 + src/models/dedicated_database_extensions.rs | 15 + src/models/dedicated_database_list.rs | 10 + src/models/dedicated_database_member.rs | 15 + src/models/dedicated_database_operation.rs | 40 + .../dedicated_database_operation_list.rs | 10 + src/models/dedicated_database_pitr_windows.rs | 10 + src/models/dedicated_database_pooler.rs | 50 + src/models/dedicated_database_replicas.rs | 30 + src/models/dedicated_database_restoration.rs | 123 +- .../dedicated_database_restoration_list.rs | 10 + .../dedicated_database_specification.rs | 121 +- .../dedicated_database_specification_list.rs | 19 +- ...edicated_database_specification_pricing.rs | 68 - src/models/deployment.rs | 130 + src/models/deployment_list.rs | 10 + src/models/dev_key.rs | 104 - src/models/document.rs | 35 + src/models/document_list.rs | 10 + src/models/email_template.rs | 40 + src/models/email_template_list.rs | 10 + src/models/embedding.rs | 20 + src/models/embedding_list.rs | 10 + src/models/ephemeral_key.rs | 45 + src/models/execution.rs | 84 +- src/models/execution_list.rs | 10 + src/models/file.rs | 80 + src/models/file_list.rs | 10 + src/models/framework.rs | 25 + src/models/framework_adapter.rs | 20 + src/models/framework_list.rs | 10 + src/models/function.rs | 175 ++ src/models/function_list.rs | 10 + src/models/headers.rs | 10 + src/models/identity.rs | 69 +- src/models/identity_list.rs | 10 + src/models/index.rs | 40 + src/models/index_list.rs | 10 + src/models/insight.rs | 70 + src/models/insight_cta.rs | 20 + src/models/insight_list.rs | 10 + src/models/jwt.rs | 5 + src/models/key.rs | 45 + src/models/key_list.rs | 10 + src/models/language.rs | 15 + src/models/language_list.rs | 10 + src/models/locale.rs | 35 + src/models/locale_code.rs | 10 + src/models/locale_code_list.rs | 10 + src/models/log.rs | 235 -- src/models/log_list.rs | 49 - src/models/membership.rs | 75 + src/models/membership_list.rs | 10 + src/models/message.rs | 50 + src/models/message_list.rs | 10 + src/models/mfa_challenge.rs | 20 + src/models/mfa_challenge_secret.rs | 25 + src/models/mfa_factors.rs | 25 + src/models/mfa_recovery_codes.rs | 5 + src/models/mfa_type.rs | 10 + src/models/mock_number.rs | 20 + src/models/mock_number_list.rs | 10 + src/models/mod.rs | 36 +- src/models/o_auth2_amazon.rs | 20 + src/models/o_auth2_apple.rs | 68 +- src/models/o_auth2_appwrite.rs | 20 + src/models/o_auth2_auth0.rs | 44 +- src/models/o_auth2_authentik.rs | 25 + src/models/o_auth2_autodesk.rs | 20 + src/models/o_auth2_bitbucket.rs | 20 + src/models/o_auth2_bitly.rs | 20 + src/models/o_auth2_box.rs | 20 + src/models/o_auth2_cloudflare.rs | 20 + src/models/o_auth2_dailymotion.rs | 20 + src/models/o_auth2_discord.rs | 39 +- src/models/o_auth2_disqus.rs | 20 + src/models/o_auth2_dropbox.rs | 20 + src/models/o_auth2_etsy.rs | 20 + src/models/o_auth2_facebook.rs | 20 + src/models/o_auth2_figma.rs | 20 + src/models/o_auth2_fusion_auth.rs | 25 + src/models/o_auth2_github.rs | 39 +- src/models/o_auth2_gitlab.rs | 25 + src/models/o_auth2_google.rs | 63 +- src/models/o_auth2_hugging_face.rs | 20 + src/models/o_auth2_keycloak.rs | 30 + src/models/o_auth2_kick.rs | 20 + src/models/o_auth2_linkedin.rs | 20 + src/models/o_auth2_microsoft.rs | 44 +- src/models/o_auth2_notion.rs | 20 + src/models/o_auth2_oidc.rs | 65 +- src/models/o_auth2_okta.rs | 49 +- src/models/o_auth2_paypal.rs | 20 + src/models/o_auth2_podio.rs | 20 + src/models/o_auth2_provider_list.rs | 10 + src/models/o_auth2_resend.rs | 20 + src/models/o_auth2_salesforce.rs | 39 +- src/models/o_auth2_slack.rs | 20 + src/models/o_auth2_spotify.rs | 20 + src/models/o_auth2_stripe.rs | 20 + src/models/o_auth2_tradeshift.rs | 20 + src/models/o_auth2_twitch.rs | 20 + src/models/o_auth2_word_press.rs | 20 + src/models/o_auth2_x.rs | 20 + src/models/o_auth2_yahoo.rs | 20 + src/models/o_auth2_yandex.rs | 20 + src/models/o_auth2_zoho.rs | 39 +- src/models/o_auth2_zoom.rs | 20 + src/models/oauth2_approve.rs | 5 + src/models/oauth2_authorize.rs | 10 + src/models/oauth2_consent.rs | 50 + src/models/oauth2_consent_list.rs | 10 + src/models/oauth2_consent_token.rs | 55 + src/models/oauth2_consent_token_list.rs | 10 + src/models/oauth2_device_authorization.rs | 30 + src/models/oauth2_grant.rs | 60 + src/models/oauth2_organization.rs | 5 + src/models/oauth2_organization_list.rs | 10 + src/models/oauth2_par.rs | 10 + src/models/oauth2_project.rs | 15 + src/models/oauth2_project_list.rs | 10 + src/models/oauth2_reject.rs | 5 + src/models/oauth2_token.rs | 25 + src/models/organization.rs | 166 +- src/models/passkey.rs | 25 + src/models/passkey_challenge.rs | 25 + src/models/passkey_list.rs | 10 + src/models/phone.rs | 15 + src/models/phone_list.rs | 10 + src/models/platform_android.rs | 44 +- src/models/platform_apple.rs | 25 + src/models/platform_linux.rs | 25 + src/models/platform_list.rs | 10 + src/models/platform_web.rs | 25 + src/models/platform_windows.rs | 25 + src/models/policy_deny_aliased_email.rs | 10 + src/models/policy_deny_corporate_email.rs | 10 + src/models/policy_deny_disposable_email.rs | 10 + src/models/policy_deny_free_email.rs | 10 + src/models/policy_list.rs | 10 + src/models/policy_membership_privacy.rs | 35 + src/models/policy_mfa_factors.rs | 25 + src/models/policy_passkey.rs | 15 + src/models/policy_password_dictionary.rs | 10 + src/models/policy_password_history.rs | 10 + src/models/policy_password_personal_data.rs | 10 + src/models/policy_password_strength.rs | 30 + src/models/policy_session_alert.rs | 10 + src/models/policy_session_duration.rs | 10 + src/models/policy_session_invalidation.rs | 10 + src/models/policy_session_limit.rs | 10 + src/models/policy_user_limit.rs | 10 + src/models/postgres_extension.rs | 20 + src/models/presence.rs | 30 + src/models/presence_list.rs | 10 + src/models/program.rs | 45 + src/models/project.rs | 139 +- src/models/project_auth_method.rs | 5 + src/models/project_list.rs | 10 + src/models/project_protocol.rs | 5 + src/models/project_service.rs | 5 + src/models/provider.rs | 40 + src/models/provider_list.rs | 10 + src/models/proxy_invalidation.rs | 20 + src/models/proxy_rule.rs | 82 +- src/models/proxy_rule_list.rs | 10 + src/models/report.rs | 55 + src/models/report_list.rs | 10 + src/models/resource_token.rs | 35 + src/models/resource_token_list.rs | 10 + src/models/row.rs | 35 + src/models/row_list.rs | 10 + src/models/runtime.rs | 40 + src/models/runtime_list.rs | 10 + src/models/session.rs | 145 ++ src/models/session_list.rs | 10 + src/models/site.rs | 165 ++ src/models/site_list.rs | 10 + src/models/specification.rs | 20 + src/models/specification_list.rs | 10 + src/models/subscriber.rs | 40 + src/models/subscriber_list.rs | 10 + src/models/table.rs | 60 + src/models/table_list.rs | 10 + src/models/target.rs | 40 + src/models/target_list.rs | 10 + src/models/team.rs | 25 + src/models/team_list.rs | 10 + src/models/token.rs | 30 + src/models/token_secret.rs | 30 + src/models/topic.rs | 44 +- src/models/topic_list.rs | 10 + src/models/transaction.rs | 30 + src/models/transaction_list.rs | 10 + src/models/usage_billing_plan.rs | 118 +- src/models/user.rs | 75 + src/models/user_list.rs | 10 + src/models/variable.rs | 40 + src/models/variable_list.rs | 10 + src/models/vectorsdb_collection.rs | 65 + src/models/vectorsdb_collection_list.rs | 10 + src/models/webhook.rs | 67 +- src/models/webhook_list.rs | 10 + src/query/builder.rs | 622 +++++ src/{query.rs => query/mod.rs} | 573 +++++ src/services/account.rs | 177 +- src/services/activities.rs | 12 +- src/services/advisor.rs | 61 +- src/services/apps.rs | 328 ++- src/services/avatars.rs | 27 +- src/services/backups.rs | 82 +- src/services/databases.rs | 1870 +++++++++++++-- src/services/documents_db.rs | 741 +++++- src/services/functions.rs | 390 ++- src/services/messaging.rs | 352 ++- src/services/mongo.rs | 503 +++- src/services/mysql.rs | 543 ++++- src/services/oauth2.rs | 47 +- src/services/organization.rs | 230 +- src/services/postgresql.rs | 591 ++++- src/services/presences.rs | 49 +- src/services/project.rs | 212 +- src/services/proxy.rs | 64 +- src/services/sites.rs | 381 ++- src/services/storage.rs | 209 +- src/services/tables_db.rs | 2092 +++++++++++++++-- src/services/teams.rs | 286 ++- src/services/tokens.rs | 85 +- src/services/users.rs | 500 +++- src/services/vectors_db.rs | 669 +++++- src/services/webhooks.rs | 49 +- src/topic.rs | 158 ++ tests/tests.rs | 110 +- 419 files changed, 20530 insertions(+), 2473 deletions(-) delete mode 100644 docs/examples/account/list-logs.md rename docs/examples/{organization/get-key.md => mongo/promote-restoration.md} (71%) rename docs/examples/{users/list-logs.md => mysql/promote-restoration.md} (68%) delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/update-key.md rename docs/examples/{organization/list-keys.md => postgresql/promote-restoration.md} (67%) rename docs/examples/{organization/delete-key.md => proxy/create-smtp-rule.md} (64%) delete mode 100644 src/enums/organization_key_scopes.rs create mode 100644 src/enums/proxy_rule_protocol.rs delete mode 100644 src/models/dedicated_database_specification_pricing.rs delete mode 100644 src/models/dev_key.rs delete mode 100644 src/models/log.rs delete mode 100644 src/models/log_list.rs create mode 100644 src/query/builder.rs rename src/{query.rs => query/mod.rs} (67%) create mode 100644 src/topic.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index ed2831c..d88c77b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.16.0] - TBD +## [0.20.0] - TBD ### Added - Initial release of Appwrite Rust SDK -- Full support for Appwrite API 2.0.0 +- Full support for Appwrite API 2.5.0 - Async/await support with tokio runtime - Built-in error handling with custom error types - File upload support with automatic chunking @@ -22,34 +22,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Automatic JSON serialization/deserialization ### Features -- Account service with 59 methods +- Account service with 71 methods - Activities service with 2 methods - Apps service with 22 methods -- Avatars service with 9 methods +- Avatars service with 11 methods - Backups service with 12 methods - Databases service with 71 methods - DocumentsDB service with 37 methods +- Domains service with 47 methods - Embeddings service with 1 methods - Functions service with 26 methods - Graphql service with 2 methods - Locale service with 8 methods -- Messaging service with 54 methods -- Mongo service with 31 methods -- Mysql service with 34 methods -- Oauth2 service with 12 methods +- Messaging service with 56 methods +- Mongo service with 32 methods +- Mysql service with 35 methods +- Oauth2 service with 13 methods - Organization service with 23 methods -- Postgresql service with 37 methods +- Postgresql service with 38 methods - Presences service with 5 methods -- Project service with 105 methods -- Proxy service with 9 methods +- Project service with 116 methods +- Proxy service with 10 methods - Advisor service with 5 methods - Sites service with 25 methods - Storage service with 13 methods - TablesDB service with 81 methods - Teams service with 18 methods - Tokens service with 5 methods -- Users service with 50 methods +- Users service with 53 methods - VectorsDB service with 36 methods +- Waf service with 13 methods - Webhooks service with 6 methods ### Services @@ -68,7 +70,6 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `list_identities()` - Get the list of identities for the currently logged in user. - `delete_identity()` - Delete an identity by its unique ID. -- `list_logs()` - 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. - `update_mfa()` - Enable or disable MFA on an account. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. - `create_mfa_authenticator()` - Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. @@ -89,6 +90,12 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_mfa_recovery_codes()` - Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - `update_name()` - Update currently logged in user account name. +- `list_passkeys()` - Get the list of verified passkeys registered by the currently logged in user. +- `create_passkey()` - 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. +- `get_passkey()` - Get a verified passkey of the currently logged in user by its unique ID. +- `update_passkey()` - Rename a passkey of the currently logged in user. +- `delete_passkey()` - 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. +- `update_passkey_verification()` - 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. - `update_password()` - Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. - `update_phone()` - Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. - `get_prefs()` - Get the preferences as a key-value object for the currently logged in user. @@ -97,12 +104,30 @@ This endpoint can also be used to convert an anonymous account to a normal one, - `update_recovery()` - 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. +- `create_recovery_otp()` - 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. + +- `update_recovery_otp()` - 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. + - `list_sessions()` - Get the list of active sessions across different devices for the currently logged in user. -- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. +- `delete_sessions()` - Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. - `create_anonymous_session()` - Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). -- `create_email_password_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. +- `create_email_password_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 limits](https://appwrite.io/docs/authentication-security#limits). +- `create_id_token_session()` - 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). + - `update_magic_url_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `update_phone_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - `create_session()` - Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -122,7 +147,11 @@ A user is limited to 10 active sessions at a time by default. [Learn more about If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create 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). +- `create_passkey_token()` - 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. +- `update_passkey_token()` - 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. - `create_phone_token()` - 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 /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. 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). @@ -136,6 +165,12 @@ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/ - `update_email_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. - `update_verification()` - Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. +- `create_email_verification_otp()` - 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. + +- `update_email_verification_otp()` - 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. + - `create_phone_verification()` - Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. - `update_phone_verification()` - Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -197,9 +232,11 @@ You can use the color and background params to change the avatar colors. By defa When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. -- `get_photo()` - 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. +- `get_photo()` - Returns the best available profile photo for a user. The endpoint tries 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, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. +- `update_photo()` - 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. +- `delete_photo()` - 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. - `get_qr()` - 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. - `get_screenshot()` - Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -332,7 +369,7 @@ The Databases service allows you to create structured collections of documents, - `increment_document_attribute()` - Increment a specific attribute of a document by a given value. - `list_indexes()` - List indexes in the collection. - `create_index()` - Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. - `get_index()` - Get an index by its unique ID. - `delete_index()` - Delete an index. @@ -341,7 +378,7 @@ Attributes can be `key`, `fulltext`, and `unique`. - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -379,6 +416,127 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Domains + +- `list()` - List all domains registered for this project. This endpoint supports pagination. +- `create()` - 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. +- `get_price()` - Get the registration price for a domain name. +- `list_prices()` - 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. +- `get()` - Get a domain by its unique ID. +- `delete()` - 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. +- `update_nameservers()` - Update the registrar nameservers for the given domain. When nameservers are not provided, +the domain will be updated to use Appwrite nameservers. +- `verify_nameservers()` - 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. +- `get_preset_google_workspace()` - List Google Workspace DNS records. +- `create_preset_google_workspace()` - Add Google Workspace DNS records to the domain. This will create the required MX records +for Google Workspace email hosting. +- `get_preset_i_cloud()` - List iCloud DNS records. +- `create_preset_i_cloud()` - Add iCloud DNS records to the domain. This will create the required MX and SPF records +for using iCloud email services with your domain. +- `get_preset_mailgun()` - List Mailgun DNS records. +- `create_preset_mailgun()` - Add Mailgun DNS records to the domain. This endpoint will create the required DNS records +for Mailgun in the specified domain. +- `get_preset_outlook()` - List Outlook DNS records. +- `create_preset_outlook()` - Add Outlook DNS records to the domain. This will create the required MX records +for setting up Outlook email hosting for your domain. +- `get_preset_proton_mail()` - List ProtonMail DNS records. +- `create_preset_proton_mail()` - Add ProtonMail DNS records to the domain. This will create the required MX records +for using ProtonMail with your custom domain. +- `get_preset_zoho()` - List Zoho DNS records. +- `create_preset_zoho()` - Add Zoho Mail DNS records to the domain. This will create the required MX records +for setting up Zoho Mail on your domain. +- `list_records()` - List DNS records for a given domain. You can use this endpoint to list all the DNS records +associated with your domain. +- `create_record_a()` - 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. +- `update_record_a()` - 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. +- `create_record_aaaa()` - 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. +- `update_record_aaaa()` - 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. +- `create_record_alias()` - 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. +- `update_record_alias()` - 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. +- `create_record_caa()` - 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. +- `update_record_caa()` - 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. +- `create_record_cname()` - 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'. +- `update_record_cname()` - Update an existing CNAME record for the given domain. +- `create_record_https()` - 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. +- `update_record_https()` - 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. +- `create_record_mx()` - 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. +- `update_record_mx()` - Update an existing MX record for the given domain. +- `create_record_ns()` - 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. +- `update_record_ns()` - 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. +- `create_record_srv()` - 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. +- `update_record_srv()` - 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 +- `create_record_txt()` - 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. +- `update_record_txt()` - 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. +- `get_record()` - 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. +- `delete_record()` - Delete a DNS record for the given domain. This endpoint allows you to delete an existing DNS record +from a specific domain. +- `update_team()` - 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. +- `get_transfer_status()` - Retrieve the current transfer status for a domain. Returns the status, an optional reason, and a timestamp of the last status change. +- `get_zone()` - 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. +- `update_zone()` - 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. + #### Embeddings - `create_text_embeddings()` - Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. @@ -463,6 +621,8 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `create_apns_provider()` - Create a new Apple Push Notification service provider. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. - `update_apns_provider()` - Update a Apple Push Notification service provider by its unique ID. +- `create_appwrite_provider()` - Create a new Appwrite push provider. +- `update_appwrite_provider()` - Update an Appwrite push provider by its unique ID. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `create_fcm_provider()` - Create a new Firebase Cloud Messaging provider. - `update_fcm_provider()` - Update a Firebase Cloud Messaging provider by its unique ID. @@ -509,7 +669,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -535,7 +695,13 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. - `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. - `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `promote_restoration()` - Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. - `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. @@ -543,7 +709,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -561,7 +727,7 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. - `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. - `update_credentials()` - Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. -- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. +- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. - `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. - `update_maintenance()` - Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. - `create_migration()` - Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. @@ -572,7 +738,13 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. - `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. - `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `promote_restoration()` - Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. - `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. @@ -584,6 +756,7 @@ The OAuth2 service allows you to authorize apps and issue standards-based OAuth2 - `create_device_authorization()` - Start the OAuth2 Device Authorization Grant. Returns the device code, user code, verification URL, expiration, and polling interval. - `create_grant()` - Exchange a device flow user code for an OAuth2 grant. The authenticated user is bound to the pending grant. Pass the returned grant ID to the get grant endpoint to render the consent screen, then to the approve or reject endpoint to complete the flow. - `get_grant()` - Get an OAuth2 grant by its ID. Used by the consent screen to display the details of the authorization the user is being asked to approve. A grant can only be read by the user it belongs to, or by server SDK. +- `introspect()` - 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. - `list_organizations()` - 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. - `create_par()` - Store an OAuth2 authorization request server-side and receive a short-lived request_uri handle for the authorize endpoint. - `list_projects()` - List the projects the OAuth2 access token can access. Resolves the token's `project` authorization details, expanding the `*` wildcard into the concrete set of projects the user can see. @@ -601,11 +774,6 @@ The Organization service allows you to manage organization-level projects. - `get_installation()` - Get an app installation on the organization by its unique ID. Any organization member can read installations. - `update_installation()` - Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked. - `delete_installation()` - Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked. -- `list_keys()` - Get a list of all API keys from the current organization. -- `create_key()` - Create a new organization API key. -- `get_key()` - Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. -- `update_key()` - Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. -- `delete_key()` - Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. - `list_memberships()` - Get a list of all memberships from the current organization. - `create_membership()` - 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. - `get_membership()` - Get a membership from the current organization by its unique ID. @@ -616,12 +784,19 @@ The Organization service allows you to manage organization-level projects. - `get_project()` - Get a project. - `update_project()` - Update a project by its unique ID. - `delete_project()` - Delete a project by its unique ID. +- `list_project_keys()` - Get a list of all API keys of a project in your organization. +- `create_ephemeral_project_key()` - Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + +You can also create a standard API key if you need a longer-lived key instead. +- `get_project_key()` - Get a project key by its unique ID. +- `update_project_key()` - Update a project key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. +- `delete_project_key()` - Delete a project key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. #### Postgresql - `list()` - List all dedicated databases. Results support pagination. - `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. - `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. - `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. @@ -639,7 +814,7 @@ The Organization service allows you to manage organization-level projects. - `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. - `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. - `update_credentials()` - Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string. -- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. +- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. - `list_extensions()` - List installed and available extensions for a PostgreSQL database. - `create_extension()` - Install a database extension. Only available for PostgreSQL databases. The install runs asynchronously; poll the extensions list endpoint for status. - `delete_extension()` - Uninstall a database extension from a PostgreSQL database. The uninstall runs asynchronously; poll the extensions list endpoint for status. @@ -653,7 +828,13 @@ The Organization service allows you to manage organization-level projects. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. - `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. - `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `promote_restoration()` - Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. - `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. @@ -675,6 +856,11 @@ The Project service allows you to manage all the projects in your Appwrite serve - `get()` - Get a project. - `delete()` - Delete a project. - `update_auth_method()` - Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. +- `list_environments()` - Get a list of all environments of the project. You can use the query params to filter your results. +- `create_environment()` - Create a new environment of the project. An environment is a separate project in the same organization and region, with its own resources and users. Its usage is billed under the project it belongs to. +- `get_environment()` - Get an environment of the project by its unique ID. +- `update_environment()` - Update the name of an environment of the project. +- `delete_environment()` - Delete an environment of the project, with all of its resources and users. - `list_keys()` - Get a list of all API keys from the current project. - `create_ephemeral_key()` - Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. @@ -712,6 +898,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_gitlab()` - Update the project OAuth2 Gitlab configuration. - `update_o_auth2_google()` - Update the project OAuth2 Google configuration. - `update_o_auth2_hugging_face()` - Update the project OAuth2 Hugging Face configuration. +- `update_o_auth2_kakao()` - Update the project OAuth2 Kakao configuration. - `update_o_auth2_keycloak()` - Update the project OAuth2 Keycloak configuration. - `update_o_auth2_kick()` - Update the project OAuth2 Kick configuration. - `update_o_auth2_linkedin()` - Update the project OAuth2 Linkedin configuration. @@ -727,9 +914,11 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_slack()` - Update the project OAuth2 Slack configuration. - `update_o_auth2_spotify()` - Update the project OAuth2 Spotify configuration. - `update_o_auth2_stripe()` - Update the project OAuth2 Stripe configuration. +- `update_o_auth2_tik_tok()` - Update the project OAuth2 TikTok configuration. - `update_o_auth2_tradeshift()` - Update the project OAuth2 Tradeshift configuration. - `update_o_auth2_tradeshift_sandbox()` - Update the project OAuth2 Tradeshift Sandbox configuration. - `update_o_auth2_twitch()` - Update the project OAuth2 Twitch configuration. +- `update_o_auth2_webflow()` - Update the project OAuth2 Webflow configuration. - `update_o_auth2_word_press()` - Update the project OAuth2 WordPress configuration. - `update_o_auth2_x()` - Update the project OAuth2 X configuration. - `update_o_auth2_yahoo()` - Update the project OAuth2 Yahoo configuration. @@ -739,7 +928,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `get_o_auth2_provider()` - Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. - `list_platforms()` - Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. - `create_android_platform()` - Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. -- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. +- `update_android_platform()` - Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. - `create_apple_platform()` - Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. - `update_apple_platform()` - Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. - `create_linux_platform()` - Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. @@ -757,11 +946,14 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_deny_free_email_policy()` - Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. - `update_membership_privacy_policy()` - Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. - `update_mfa_factors_policy()` - Updating this policy allows you to control which factors users can use to complete an MFA challenge. Disabled factors cannot be used to create a challenge and are reported as unavailable when listing factors. The custom factor is disabled by default; enable it to deliver challenge codes through your own channel. Recovery codes always remain available as a fallback. +- `update_passkey_policy()` - 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. - `update_password_dictionary_policy()` - 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. - `update_password_history_policy()` - Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. - `update_password_personal_data_policy()` - Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. +- `update_password_pwned_policy()` - 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. +- `update_password_rotation_policy()` - 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. - `update_password_strength_policy()` - Update the password strength requirements for users in the project. - `update_session_alert_policy()` - Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. - `update_session_duration_policy()` - Update maximum duration how long sessions created within a project should stay active for. @@ -787,6 +979,8 @@ The Proxy Service allows you to configure actions for your domains beyond DNS co - `create_invalidation()` - Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. 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. - `list_rules()` - Get a list of all the proxy rules. You can use the query params to filter your results. - `create_api_rule()` - Create a new proxy rule for serving Appwrite's API on custom domain. @@ -800,6 +994,7 @@ Rule ID is automatically generated as MD5 hash of a rule domain for performance - `create_site_rule()` - Create a new proxy rule for serving Appwrite Site on custom domain. Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. +- `create_smtp_rule()` - Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. - `get_rule()` - Get a proxy rule by its unique ID. - `delete_rule()` - Delete a proxy rule by its unique ID. - `update_rule_status()` - If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. @@ -877,7 +1072,7 @@ The TablesDB service allows you to create structured tables of columns, query an - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -889,10 +1084,10 @@ The TablesDB service allows you to create structured tables of columns, query an - `delete()` - Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. - `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. - `list_migrations()` - List the dedicated migrations for a TablesDB database. A database has at most one in-flight migration. -- `create_migration()` - Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. +- `create_migration()` - Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. - `get_migration()` - Get a single dedicated migration for a TablesDB database by its ID. - `delete_migration()` - Abort an in-flight TablesDB dedicated migration. Only allowed before cutover; once the migration has cut over it cannot be aborted. -- `create_cutover()` - Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. +- `create_cutover()` - Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. - `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. @@ -946,6 +1141,8 @@ The TablesDB service allows you to create structured tables of columns, query an - `update_polygon_column()` - Update a polygon column. Changing the `default` value will not update already existing rows. - `create_relationship_column()` - Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). +- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + - `create_string_column()` - Create a string column. - `update_string_column()` - Update a string column. Changing the `default` value will not update already existing rows. @@ -964,11 +1161,9 @@ The TablesDB service allows you to create structured tables of columns, query an - `get_column()` - Get column by ID. - `delete_column()` - Deletes a column. -- `update_relationship_column()` - Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - - `list_indexes()` - List indexes on the table. - `create_index()` - Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. - `get_index()` - Get index by ID. - `delete_index()` - Delete an index. - `list_rows()` - Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -1041,13 +1236,12 @@ The Users service allows you to manage your project users. - `get()` - Get a user by its unique ID. - `delete()` - Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. - `update_email()` - Update the user email by its unique ID. -- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +- `update_impersonator()` - Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. 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. - `create_jwt()` - Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. - `update_labels()` - Update the user labels by its unique ID. Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. -- `list_logs()` - Get the user activity logs list by its unique ID. - `list_memberships()` - Get the user membership list by its unique ID. - `update_mfa()` - Enable or disable MFA on a user account. - `update_mfa()` - Enable or disable MFA on a user account. @@ -1063,6 +1257,10 @@ Labels can be used to grant access to resources. While teams are a way for user& - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `create_mfa_recovery_codes()` - Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. - `update_name()` - Update the user name by its unique ID. +- `list_passkeys()` - Get the list of verified passkeys registered by a user. +- `get_passkey()` - Get a verified passkey of a user by its unique ID. +- `update_passkey()` - Rename a passkey of a user. +- `delete_passkey()` - Delete a passkey from a user, for example when a device is lost. The passkey can no longer be used to sign in. - `update_password()` - Update the user password by its unique ID. - `update_phone()` - Update the user phone by its unique ID. - `get_prefs()` - Get the user preferences by its unique ID. @@ -1089,7 +1287,7 @@ If you want to generate a token for a custom authentication flow, use the [POST - `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - `create()` - Create a new Database. -- `list_specifications()` - 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. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. - `list_transactions()` - List transactions across all databases. - `create_transaction()` - Create a new transaction. - `get_transaction()` - Get a transaction by its unique ID. @@ -1127,6 +1325,35 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. - `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +#### Waf + +- `list_rules()` - List WAF rules for the current project. + +- `create_bypass_rule()` - 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. + +- `update_bypass_rule()` - 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. + +- `create_challenge_rule()` - 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. + +- `update_challenge_rule()` - 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. + +- `create_deny_rule()` - 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. + +- `update_deny_rule()` - 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. + +- `create_rate_limit_rule()` - 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. + +- `update_rate_limit_rule()` - 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. + +- `create_redirect_rule()` - 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. + +- `update_redirect_rule()` - 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. + +- `get_rule()` - Get a WAF rule by its ID. + +- `delete_rule()` - Delete a WAF rule. + + #### Webhooks The Webhooks service allows you to manage your project webhooks. - `list()` - Get a list of all webhooks belonging to the project. You can use the query params to filter your results. @@ -1149,7 +1376,6 @@ The Webhooks service allows you to manage your project webhooks. - `UserList` - Users List - `SessionList` - Sessions List - `IdentityList` - Identities List -- `LogList` - Logs List - `FileList` - Files List - `BucketList` - Buckets List - `ResourceTokenList` - Resource Tokens List @@ -1236,7 +1462,6 @@ The Webhooks service allows you to manage your project webhooks. - `Row` - Row - `Document` - Document - `Presence` - Presence -- `Log` - Log - `User` - User - `AlgoMd5` - AlgoMD5 - `AlgoSha` - AlgoSHA @@ -1245,6 +1470,7 @@ The Webhooks service allows you to manage your project webhooks. - `AlgoScrypt` - AlgoScrypt - `AlgoScryptModified` - AlgoScryptModified - `AlgoArgon2` - AlgoArgon2 +- `Account` - Account - `Preferences` - Preferences - `Session` - Session - `Identity` - Identity @@ -1271,7 +1497,6 @@ The Webhooks service allows you to manage your project webhooks. - `Webhook` - Webhook - `Key` - Key - `EphemeralKey` - Ephemeral Key -- `DevKey` - DevKey - `MockNumber` - Mock Number - `OAuth2Github` - OAuth2GitHub - `OAuth2Discord` - OAuth2Discord @@ -1288,6 +1513,7 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Yandex` - OAuth2Yandex - `OAuth2X` - OAuth2X - `OAuth2WordPress` - OAuth2WordPress +- `OAuth2Webflow` - OAuth2Webflow - `OAuth2Twitch` - OAuth2Twitch - `OAuth2Stripe` - OAuth2Stripe - `OAuth2Spotify` - OAuth2Spotify @@ -1317,11 +1543,15 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Apple` - OAuth2Apple - `OAuth2Microsoft` - OAuth2Microsoft - `OAuth2Resend` - OAuth2Resend +- `OAuth2TikTok` - OAuth2TikTok +- `OAuth2Kakao` - OAuth2Kakao - `OAuth2ProviderList` - OAuth2 Providers List - `PolicyPasswordDictionary` - Policy Password Dictionary - `PolicyPasswordHistory` - Policy Password History - `PolicyPasswordStrength` - Policy Password Strength - `PolicyPasswordPersonalData` - Policy Password Personal Data +- `PolicyPasswordPwned` - Policy Password Pwned +- `PolicyPasswordRotation` - Policy Password Rotation - `PolicySessionAlert` - Policy Session Alert - `PolicySessionDuration` - Policy Session Duration - `PolicySessionInvalidation` - Policy Session Invalidation @@ -1329,6 +1559,11 @@ The Webhooks service allows you to manage your project webhooks. - `PolicyUserLimit` - Policy User Limit - `PolicyMembershipPrivacy` - Policy Membership Privacy - `PolicyMfaFactors` - Policy MFA Factors +- `PolicyPasskey` - Policy Passkey +- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email +- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email +- `PolicyDenyFreeEmail` - Policy Deny Free Email +- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `PlatformWeb` - Platform Web - `PlatformApple` - Platform Apple - `PlatformAndroid` - Platform Android @@ -1347,6 +1582,10 @@ The Webhooks service allows you to manage your project webhooks. - `EmailTemplate` - EmailTemplate - `MfaChallenge` - MFA Challenge - `MfaChallengeSecret` - MFA Challenge Secret +- `TokenSecret` - Token Secret +- `Passkey` - Passkey +- `PasskeyChallenge` - Passkey Challenge +- `PasskeyList` - Passkeys List - `MfaRecoveryCodes` - MFA Recovery Codes - `MfaType` - MFAType - `MfaFactors` - MFAFactors @@ -1381,6 +1620,10 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseExecutionColumn` - ExecutionColumn - `DedicatedDatabaseRestoration` - Restoration - `DatabaseStatus` - Status +- `DnsRecord` - DNSRecord +- `Domain` - Domain +- `DomainPrice` - DomainPrice +- `DomainTransferStatus` - domainTransferStatus - `DedicatedDatabaseExtensions` - Extensions - `DedicatedDatabaseMember` - Member - `DedicatedDatabaseOperation` - Operation @@ -1390,10 +1633,6 @@ The Webhooks service allows you to manage your project webhooks. - `Organization` - Organization - `DedicatedDatabasePITRWindows` - PITRWindows - `BackupPolicy` - backup -- `PolicyDenyAliasedEmail` - Policy Deny Aliased Email -- `PolicyDenyDisposableEmail` - Policy Deny Disposable Email -- `PolicyDenyFreeEmail` - Policy Deny Free Email -- `PolicyDenyCorporateEmail` - Policy Deny Corporate Email - `DedicatedDatabasePooler` - PoolerConfig - `PostgresExtension` - Postgres extension - `Program` - Program @@ -1401,7 +1640,6 @@ The Webhooks service allows you to manage your project webhooks. - `DedicatedDatabaseRestorationList` - Dedicated database restorations list - `DedicatedDatabaseSpecification` - Specification - `DedicatedDatabaseSpecificationList` - SpecificationList -- `DedicatedDatabaseSpecificationPricing` - SpecificationPricing - `DatabaseStatusConnections` - Connections - `DatabaseStatusReplica` - Replica - `DatabaseStatusVolume` - Volume @@ -1419,8 +1657,15 @@ The Webhooks service allows you to manage your project webhooks. - `Oauth2DeviceAuthorization` - OAuth2 Device Authorization - `Oauth2PAR` - OAuth2 PAR - `Oauth2Token` - OAuth2 Token +- `Oauth2Introspection` - OAuth2 Introspection - `Oauth2Consent` - OAuth2 Consent - `Oauth2ConsentToken` - OAuth2 Consent Token +- `WafRuleBypass` - WafRuleBypass +- `WafRuleDeny` - WafRuleDeny +- `WafRuleChallenge` - WafRuleChallenge +- `WafRuleRateLimit` - WafRuleRateLimit +- `WafRuleRedirect` - WafRuleRedirect +- `WafRuleList` - WAF rule list - `Oauth2Project` - OAuth2 Project - `Oauth2Organization` - OAuth2 Organization - `Oauth2ProjectList` - OAuth2 accessible projects list @@ -1433,6 +1678,9 @@ The Webhooks service allows you to manage your project webhooks. - `BackupRestorationList` - Backup restoration list - `DatabaseMigrationList` - Database Migrations List - `DedicatedDatabaseList` - Dedicated databases list +- `DnsRecordsList` - DNS records list +- `DomainPricesList` - Domain prices list +- `DomainsList` - Domains list - `AppsList` - Apps list - `AppSecretList` - App secrets list - `AppScopeList` - App scopes list @@ -1453,4 +1701,4 @@ The Webhooks service allows you to manage your project webhooks. - File upload examples - Query builder documentation -[0.16.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.16.0 +[0.20.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.20.0 diff --git a/Cargo.toml b/Cargo.toml index b5198a4..784ba2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "appwrite" -version = "0.19.0" +version = "0.20.0" edition = "2021" rust-version = "1.83" authors = ["appwrite"] diff --git a/README.md b/README.md index 3b784e1..26523cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Appwrite Rust SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-rust.svg) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg) [![Crates.io](https://img.shields.io/crates/v/appwrite.svg)](https://crates.io/crates/appwrite) [![Documentation](https://docs.rs/appwrite/badge.svg)](https://docs.rs/appwrite) -**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-rust/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-rust/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 Rust 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) @@ -17,7 +17,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -appwrite = "0.19.0" +appwrite = "0.20.0" tokio = { version = "1.48", features = ["full"] } ``` diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index a6f2987..6314ff5 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent_token( + account.delete_consent_token( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index 084f1c6..c850bcd 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.delete_consent( + account.delete_consent( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 8f332bf..0000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,23 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Account; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_session(""); // The user session to authenticate with - - let account = Account::new(&client); - - let result = account.list_logs( - Some(vec![]), // optional - Some(false) // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index 320dac4..8abf001 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_installation( + apps.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index 1d3bf37..2b3c9ae 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_key( + apps.delete_key( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index 1fa363c..86ba5da 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_secret( + apps.delete_secret( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index febc173..dc71045 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete_tokens( + apps.delete_tokens( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index 84d8cfd..ab57e98 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let apps = Apps::new(&client); - let result = apps.delete( + apps.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index d75868a..5929752 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_archive( + backups.delete_archive( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index 05e44f4..2368cc2 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let backups = Backups::new(&client); - let result = backups.delete_policy( + backups.delete_policy( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index f469178..249a02f 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index b7389d9..8e7aeef 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DatabasesIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 2d75876..7642b78 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 6ef035f..e37391a 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1c60d5c..5154b92 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index 2b7534c..3ace295 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::DocumentsDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index be2ad02..f2807ca 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index d6ba165..40e58ed 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = documents_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 8f945bb..de4f2e5 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let embeddings = Embeddings::new(&client); let result = embeddings.create_text_embeddings( - vec![], + vec!["Appwrite helps developers build applications.".into(), "Find documents with semantic search.".into()], Some(appwrite::enums::EmbeddingModel::NomicEmbedText) // optional ).await?; diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 0ef1cfa..b452dc5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -34,7 +34,8 @@ async fn main() -> Result<(), Box> { Some("s-1vcpu-512mb"), // optional Some("s-1vcpu-512mb"), // optional Some(0), // optional - Some(0) // optional + Some(0), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 2a28b83..0746b1e 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = messaging.create_twilio_provider( "", "", - Some("+12065550100"), // optional + Some(""), // optional Some(""), // optional Some(""), // optional Some(false) // optional diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 2e93a7a..e1028f2 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -16,7 +16,10 @@ async fn main() -> Result<(), Box> { Some("backup"), // optional Some(""), // optional Some(""), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("in_place"), // optional + Some(""), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md index 9114d69..05d5d23 100644 --- a/docs/examples/mongo/delete-backup-policy.md +++ b/docs/examples/mongo/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup_policy( + mongo.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md index d596d40..b992f13 100644 --- a/docs/examples/mongo/delete-backup.md +++ b/docs/examples/mongo/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete_backup( + mongo.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md index 777f263..3f9734f 100644 --- a/docs/examples/mongo/delete.md +++ b/docs/examples/mongo/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mongo = Mongo::new(&client); - let result = mongo.delete( + mongo.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/mongo/promote-restoration.md similarity index 71% rename from docs/examples/organization/get-key.md rename to docs/examples/mongo/promote-restoration.md index 2d01434..4164174 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/mongo/promote-restoration.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Organization; +use appwrite::services::Mongo; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,10 +9,11 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let organization = Organization::new(&client); + let mongo = Mongo::new(&client); - let result = organization.get_key( - "" + let result = mongo.promote_restoration( + "", + "" ).await?; let _ = result; diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index f194175..269a70a 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -16,7 +16,10 @@ async fn main() -> Result<(), Box> { Some("backup"), // optional Some(""), // optional Some(""), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("in_place"), // optional + Some(""), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md index 39ae07e..2e859af 100644 --- a/docs/examples/mysql/delete-backup-policy.md +++ b/docs/examples/mysql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup_policy( + mysql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md index 2e0b931..40b6302 100644 --- a/docs/examples/mysql/delete-backup.md +++ b/docs/examples/mysql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete_backup( + mysql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md index db5d332..ab8b4b9 100644 --- a/docs/examples/mysql/delete.md +++ b/docs/examples/mysql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let mysql = Mysql::new(&client); - let result = mysql.delete( + mysql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/mysql/promote-restoration.md similarity index 68% rename from docs/examples/users/list-logs.md rename to docs/examples/mysql/promote-restoration.md index 6f5b333..966d742 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/mysql/promote-restoration.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Users; +use appwrite::services::Mysql; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,12 +9,11 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let users = Users::new(&client); + let mysql = Mysql::new(&client); - let result = users.list_logs( - "", - Some(vec![]), // optional - Some(false) // optional + let result = mysql.promote_restoration( + "", + "" ).await?; let _ = result; diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index ff39bf6..ee6c153 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 2593e9b..45ada9f 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index db2c875..3a93e0b 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some(""), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index c894372..a026965 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index a208289..6bf1198 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 3e344a2..f334c66 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(""), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index eecf973..8bc0d41 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some("https://example.com"), // optional - Some(""), // optional + Some(vec![]), // optional Some("") // optional ).await?; diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index fbd475d..8270c93 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index c440370..6f32686 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 30c6e9f..d21afc2 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index a303692..645c41d 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 9469837..638b47e 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use appwrite::services::Oauth2; async fn main() -> Result<(), Box> { let client = Client::new(); client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_session(""); // The user session to authenticate with client.set_project(""); // Your project ID + client.set_session(""); // The user session to authenticate with let oauth2 = Oauth2::new(&client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 5ec24d8..0000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.create_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index d4cb99d..af3dc97 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let organization = Organization::new(&client); - let result = organization.delete_installation( + organization.delete_installation( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index a798005..0000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,25 +0,0 @@ -```rust -use appwrite::Client; -use appwrite::services::Organization; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = Client::new(); - client.set_endpoint("https://.cloud.appwrite.io/v1"); // Your API Endpoint - client.set_project(""); // Your project ID - client.set_key(""); // Your secret API key - - let organization = Organization::new(&client); - - let result = organization.update_key( - "", - "", - vec![appwrite::enums::OrganizationKeyScopes::ProjectsRead], - Some("2020-10-15T06:38:00.000+00:00") // optional - ).await?; - - let _ = result; - - Ok(()) -} -``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index bac2e85..52bf142 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -16,7 +16,10 @@ async fn main() -> Result<(), Box> { Some("backup"), // optional Some(""), // optional Some(""), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("in_place"), // optional + Some(""), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md index 1362635..4eeef55 100644 --- a/docs/examples/postgresql/delete-backup-policy.md +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup_policy( + postgresql.delete_backup_policy( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md index f30ba45..f5ba8fd 100644 --- a/docs/examples/postgresql/delete-backup.md +++ b/docs/examples/postgresql/delete-backup.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete_backup( + postgresql.delete_backup( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md index 4d9207e..8a966ce 100644 --- a/docs/examples/postgresql/delete.md +++ b/docs/examples/postgresql/delete.md @@ -11,12 +11,10 @@ async fn main() -> Result<(), Box> { let postgresql = Postgresql::new(&client); - let result = postgresql.delete( + postgresql.delete( "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/postgresql/promote-restoration.md similarity index 67% rename from docs/examples/organization/list-keys.md rename to docs/examples/postgresql/promote-restoration.md index 1466645..7813d3d 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Organization; +use appwrite::services::Postgresql; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,11 +9,11 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let organization = Organization::new(&client); + let postgresql = Postgresql::new(&client); - let result = organization.list_keys( - Some(vec![]), // optional - Some(false) // optional + let result = postgresql.promote_restoration( + "", + "" ).await?; let _ = result; diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 93d1dc4..357e4d6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.create_ephemeral_key( - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], 600 ).await?; diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index cb5f2ce..a62073f 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); project.create_smtp_test( - vec![] + vec!["recipient@example.com".into()] ).await?; Ok(()) diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 12b0282..1c6148a 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = project.update_key( "", "", - vec![appwrite::enums::ProjectKeyScopes::ProjectRead], + vec![appwrite::enums::ProjectKeyScopes::UsersRead], Some("2020-10-15T06:38:00.000+00:00") // optional ).await?; diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index 541993e..e9b0ea4 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.update_labels( - vec![] + vec!["production".into()] ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index f96eb6e..4f8dbdd 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,8 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_kakao( Some(""), // optional Some(""), // optional - Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/organization/delete-key.md b/docs/examples/proxy/create-smtp-rule.md similarity index 64% rename from docs/examples/organization/delete-key.md rename to docs/examples/proxy/create-smtp-rule.md index 34a1e1b..4f6c0e2 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -1,6 +1,6 @@ ```rust use appwrite::Client; -use appwrite::services::Organization; +use appwrite::services::Proxy; #[tokio::main] async fn main() -> Result<(), Box> { @@ -9,12 +9,16 @@ async fn main() -> Result<(), Box> { client.set_project(""); // Your project ID client.set_key(""); // Your secret API key - let organization = Organization::new(&client); + let proxy = Proxy::new(&client); - organization.delete_key( - "" + let result = proxy.create_smtp_rule( + "example.com", + "", + Some("") // optional ).await?; + let _ = result; + Ok(()) } ``` diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 7e5d915..d837d4e 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let sites = Sites::new(&client); - let result = sites.delete_log( + sites.delete_log( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 409d88d..725a771 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::TablesDBIndexType::Key, - vec![], + vec!["username".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index b5722c4..86e0b5c 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 36606d6..d3ebd3d 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let tables_db = TablesDB::new(&client); - let result = tables_db.delete_migration( + tables_db.delete_migration( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 92520ae..e1fe9bc 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.delete_rows( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index ba84a60..94e26a9 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.upsert_rows( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O'Brien","age":30,"isAdmin":false})], Some("") // optional ).await?; diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index bb83298..14400af 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = teams.create_membership( "", - vec![], + vec!["editor".into()], Some("email@example.com"), // optional Some(""), // optional Some("+12065550100"), // optional diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index b635b14..6af98a5 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -11,13 +11,11 @@ async fn main() -> Result<(), Box> { let teams = Teams::new(&client); - let result = teams.delete_installation( + teams.delete_installation( "", "" ).await?; - let _ = result; - Ok(()) } ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 6c6d0d7..512671a 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = teams.update_membership( "", "", - vec![] + vec!["editor".into()] ).await?; let _ = result; diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 00922e3..9305ebb 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = users.update_labels( "", - vec![] + vec!["subscriber".into()] ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index 1010288..f539c40 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - 1, + 4, Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index d2aff1f..b8c30b6 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index 02d30e2..f686c4e 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", "", appwrite::enums::VectorsDBIndexType::HnswEuclidean, - vec![], + vec!["embeddings".into()], Some(vec![appwrite::enums::OrderBy::Asc]), // optional Some(vec![]) // optional ).await?; diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index cc1aaca..bc8db2b 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.create_operations( "", - Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"name":"Walter O'Brien"}})]) // optional + Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}}})]) // optional ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index a69a6a7..fc80819 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.delete_documents( "", "", - Some(vec![]), // optional + Some(vec!["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}".into()]), // optional Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 86309ba..4256276 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { "", "", "", - Some(1), // optional + Some(4), // optional Some(vec![Permission::read(Role::any()).to_string()]), // optional Some(false), // optional Some(false) // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index c556118..5f120e9 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = vectors_db.upsert_documents( "", "", - vec![], + vec![serde_json::json!({"$id":"example1","embeddings":[0.12,-0.55,0.88,1.02],"metadata":{"name":"First document"}})], Some("") // optional ).await?; diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index a14a6c1..2862ee9 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "https://example.com/webhook", "", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 73d636d..407ea25 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "", "https://example.com/webhook", - vec![], + vec!["users.*.create".into()], Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/src/client.rs b/src/client.rs index 946094f..50bb70c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -59,6 +59,12 @@ impl Default for UploadOptions { } } +#[derive(Debug, Clone, Copy)] +enum ResponseFormat { + Json, + Text, +} + /// Appwrite client for making API requests #[derive(Debug, Clone)] pub struct Client { @@ -91,11 +97,11 @@ impl Client { /// Create a new Appwrite client pub fn new() -> Self { let mut headers = HeaderMap::new(); - headers.insert("X-Appwrite-Response-Format", "2.0.0".parse().unwrap()); + headers.insert("X-Appwrite-Response-Format", "2.5.0".parse().unwrap()); headers.insert( "user-agent", format!( - "AppwriteRustSDK/0.19.0 ({}; {})", + "AppwriteRustSDK/0.20.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH ) @@ -105,7 +111,7 @@ impl Client { headers.insert("x-sdk-name", "Rust".parse().unwrap()); headers.insert("x-sdk-platform", "server".parse().unwrap()); headers.insert("x-sdk-language", "rust".parse().unwrap()); - headers.insert("x-sdk-version", "0.19.0".parse().unwrap()); + headers.insert("x-sdk-version", "0.20.0".parse().unwrap()); let config = Config { endpoint: "https://cloud.appwrite.io/v1".to_string(), @@ -289,21 +295,6 @@ impl Client { self.clone() } - /// Set DevKey - /// - /// Your secret dev API key - pub fn set_dev_key>(&self, value: S) -> Self { - let value = value.into(); - self.state.rcu(|state| { - let mut next = (**state).clone(); - next.config - .headers - .insert("x-appwrite-dev-key", value.clone().parse().unwrap()); - Arc::new(next) - }); - self.clone() - } - /// Set Cookie /// /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -554,36 +545,27 @@ impl Client { headers: Option>, params: Option>, ) -> Result { - let response = self.request(method, path, headers, params).await?; - self.handle_response(response).await - } - - /// Make an API call that returns a plain-text body as a UTF-8 string - pub async fn call_text( - &self, - method: Method, - path: &str, - headers: Option>, - params: Option>, - ) -> Result { - let response = self.request(method, path, headers, params).await?; - if response.status().is_success() { - return Ok(response.text().await?); - } - self.handle_response::(response) + self.send(method, path, headers, params, ResponseFormat::Json) .await - .map(|_| String::new()) } - async fn request( + async fn send( &self, method: Method, path: &str, headers: Option>, params: Option>, - ) -> Result { + format: ResponseFormat, + ) -> Result { let state = self.state.load_full(); let url = format!("{}{}", state.config.endpoint, path); + let is_multipart = method != Method::GET + && headers.as_ref().is_some_and(|headers| { + headers.iter().any(|(key, value)| { + key.eq_ignore_ascii_case("content-type") + && value.eq_ignore_ascii_case("multipart/form-data") + }) + }); let mut request_builder; if let Some(params) = params { @@ -600,21 +582,36 @@ impl Client { request_builder = state.http.request(method.clone(), url_with_params); } else { request_builder = state.http.request(method.clone(), &url); - request_builder = request_builder.json(¶ms); + if is_multipart { + let mut form = multipart::Form::new(); + for (key, value) in Self::flatten_multipart_params(¶ms, "") { + form = form.text(key, value); + } + request_builder = request_builder.multipart(form); + } else { + request_builder = request_builder.json(¶ms); + } } } else { request_builder = state.http.request(method.clone(), &url); } - request_builder = request_builder.headers(state.config.headers.clone()); + let mut default_headers = state.config.headers.clone(); + if is_multipart { + default_headers.remove("content-type"); + } + request_builder = request_builder.headers(default_headers); if let Some(custom_headers) = headers { for (key, value) in custom_headers { - request_builder = request_builder.header(key, value); + if !is_multipart || !key.eq_ignore_ascii_case("content-type") { + request_builder = request_builder.header(key, value); + } } } - Ok(request_builder.send().await?) + let response = request_builder.send().await?; + self.handle_response(response, format).await } /// Make an API call that returns a location/redirect URL (for webAuth endpoints) @@ -801,7 +798,19 @@ impl Client { } } - /// Upload a file + /// Make an API call that returns a plain-text body as a UTF-8 string + pub async fn call_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: Option>, + ) -> Result { + self.send(method, path, headers, params, ResponseFormat::Text) + .await + } + + /// Upload a file with POST pub async fn file_upload( &self, path: &str, @@ -824,7 +833,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method - #[allow(clippy::too_many_arguments)] pub async fn upload( &self, method: Method, @@ -851,7 +859,69 @@ impl Client { .await } - /// Upload a file with progress callback + /// Upload a file in one request whatever the configured chunk size, for + /// endpoints that do not accept chunked uploads + pub async fn single_upload( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) + .await + } + + /// Upload a file with POST and return the plain-text response body + pub async fn file_upload_text( + &self, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + self.upload_text(Method::POST, path, headers, params, param_name, input_file) + .await + } + + /// Upload a file with the endpoint's HTTP method and return the plain-text response body + pub async fn upload_text( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + ) -> Result { + let url = format!("{}{}", self.state.load().config.endpoint, path); + + self.single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Text, + ) + .await + } + + /// Upload a file with POST and a progress callback pub async fn file_upload_with_progress( &self, path: &str, @@ -877,7 +947,6 @@ impl Client { } /// Upload a file with the endpoint's HTTP method and a progress callback - #[allow(clippy::too_many_arguments)] pub async fn upload_with_progress( &self, method: Method, @@ -902,7 +971,15 @@ impl Client { let url = format!("{}{}", state.config.endpoint, path); let result = self - .single_file_upload(method, &url, headers, params, param_name, &input_file) + .single_file_upload( + method, + &url, + headers, + params, + param_name, + &input_file, + ResponseFormat::Json, + ) .await?; if let Some(callback) = &options.on_progress { @@ -929,22 +1006,6 @@ impl Client { .await } - /// Upload a file in one request, whatever the configured chunk size, for - /// endpoints that do not accept chunked uploads - pub(crate) async fn single_upload( - &self, - method: Method, - path: &str, - headers: Option>, - params: HashMap, - param_name: &str, - input_file: InputFile, - ) -> Result { - let url = format!("{}{}", self.state.load_full().config.endpoint, path); - self.single_file_upload(method, &url, headers, params, param_name, &input_file) - .await - } - async fn single_file_upload( &self, method: Method, @@ -953,6 +1014,7 @@ impl Client { params: HashMap, param_name: &str, input_file: &InputFile, + format: ResponseFormat, ) -> Result { let state = self.state.load_full(); let mut form = multipart::Form::new(); @@ -997,10 +1059,9 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, format).await } - #[allow(clippy::too_many_arguments)] async fn chunked_file_upload_with_progress( &self, method: Method, @@ -1099,6 +1160,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1106,7 +1168,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1160,6 +1221,7 @@ impl Client { while tasks.len() < max_concurrency && next_chunk < total_chunks { let client = self.clone(); + let method = method.clone(); let path = path.to_string(); let headers = headers.clone(); let params = params.clone(); @@ -1167,7 +1229,6 @@ impl Client { let input_file = input_file.clone(); let upload_id = current_upload_id.clone(); let chunk_index = next_chunk; - let method = method.clone(); tasks.spawn(async move { let result = client @@ -1279,10 +1340,14 @@ impl Client { let response = request_builder.multipart(form).send().await?; - self.handle_response(response).await + self.handle_response(response, ResponseFormat::Json).await } - async fn handle_response(&self, response: Response) -> Result { + async fn handle_response( + &self, + response: Response, + format: ResponseFormat, + ) -> Result { let status = response.status(); let content_type = response .headers() @@ -1295,6 +1360,19 @@ impl Client { if status.is_success() { let bytes = response.bytes().await?; + if let ResponseFormat::Text = format { + let text = String::from_utf8(bytes.to_vec()).map_err(|e| { + AppwriteError::new( + 0, + format!("Invalid UTF-8 response: {}", e), + None, + String::from_utf8_lossy(e.as_bytes()).to_string(), + ) + })?; + + return Ok(serde_json::from_value(Value::String(text))?); + } + if !content_type.is_empty() && !content_type.starts_with("application/json") && !bytes.is_empty() @@ -1350,6 +1428,7 @@ impl Client { #[cfg(test)] mod tests { use super::*; + use crate::query::Query; #[test] fn test_client_creation() { @@ -1366,4 +1445,60 @@ mod tests { assert_eq!(client.endpoint(), "https://custom.example.com/v1"); } + + async fn mock_server() -> wiremock::MockServer { + let server = wiremock::MockServer::start().await; + wiremock::Mock::given(wiremock::matchers::any()) + .respond_with(wiremock::ResponseTemplate::new(200).set_body_json(serde_json::json!({}))) + .mount(&server) + .await; + server + } + + fn params() -> HashMap { + HashMap::from([ + ("values".to_string(), serde_json::json!([["a", "b"]])), + ( + "queries".to_string(), + serde_json::json!(Query::builder().limit(1)), + ), + ]) + } + + #[tokio::test] + async fn json_body_keeps_nested_string_arrays() { + let server = mock_server().await; + let client = Client::new().set_endpoint(server.uri()); + let headers = HashMap::from([("content-type".to_string(), "application/json".to_string())]); + + let _: Value = client + .call(Method::POST, "/", Some(headers), Some(params())) + .await + .unwrap(); + + let requests = server.received_requests().await.unwrap(); + let body: Value = serde_json::from_slice(&requests[0].body).unwrap(); + assert_eq!(body["values"], serde_json::json!([["a", "b"]])); + assert_eq!( + body["queries"], + serde_json::json!([Query::limit(1).to_string()]) + ); + } + + #[tokio::test] + async fn query_string_keeps_nested_string_arrays() { + let server = mock_server().await; + let client = Client::new().set_endpoint(server.uri()); + + let _: Value = client + .call(Method::GET, "/", None, Some(params())) + .await + .unwrap(); + + let requests = server.received_requests().await.unwrap(); + let pairs: Vec<(String, String)> = requests[0].url.query_pairs().into_owned().collect(); + assert!(pairs.contains(&("values[]".to_string(), "[\"a\",\"b\"]".to_string()))); + assert!(pairs.contains(&("queries[]".to_string(), Query::limit(1).to_string()))); + assert_eq!(pairs.len(), 2); + } } diff --git a/src/enums/billing_plan_group.rs b/src/enums/billing_plan_group.rs index 9557243..e8b9ed3 100644 --- a/src/enums/billing_plan_group.rs +++ b/src/enums/billing_plan_group.rs @@ -2,10 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum BillingPlanGroup { - #[serde(rename = "starter")] - #[default] - Starter, #[serde(rename = "free")] + #[default] Free, #[serde(rename = "start")] Start, @@ -19,7 +17,6 @@ impl BillingPlanGroup { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { - BillingPlanGroup::Starter => "starter", BillingPlanGroup::Free => "free", BillingPlanGroup::Start => "start", BillingPlanGroup::Pro => "pro", diff --git a/src/enums/execution_method.rs b/src/enums/execution_method.rs index 6764169..5dc4639 100644 --- a/src/enums/execution_method.rs +++ b/src/enums/execution_method.rs @@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ExecutionMethod { #[serde(rename = "GET")] - #[default] GET, #[serde(rename = "POST")] + #[default] POST, #[serde(rename = "PUT")] PUT, diff --git a/src/enums/execution_trigger.rs b/src/enums/execution_trigger.rs index 46fb2cd..201e671 100644 --- a/src/enums/execution_trigger.rs +++ b/src/enums/execution_trigger.rs @@ -9,6 +9,8 @@ pub enum ExecutionTrigger { Schedule, #[serde(rename = "event")] Event, + #[serde(rename = "email")] + Email, } impl ExecutionTrigger { @@ -18,6 +20,7 @@ impl ExecutionTrigger { ExecutionTrigger::Http => "http", ExecutionTrigger::Schedule => "schedule", ExecutionTrigger::Event => "event", + ExecutionTrigger::Email => "email", } } } diff --git a/src/enums/image_gravity.rs b/src/enums/image_gravity.rs index 202aa5e..5114a01 100644 --- a/src/enums/image_gravity.rs +++ b/src/enums/image_gravity.rs @@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] pub enum ImageGravity { + #[serde(rename = "auto")] + Auto, #[serde(rename = "center")] #[default] Center, @@ -21,14 +23,13 @@ pub enum ImageGravity { Bottom, #[serde(rename = "bottom-right")] BottomRight, - #[serde(rename = "auto")] - Auto, } impl ImageGravity { /// Get the string value of the enum pub fn as_str(&self) -> &str { match self { + ImageGravity::Auto => "auto", ImageGravity::Center => "center", ImageGravity::TopLeft => "top-left", ImageGravity::Top => "top", @@ -38,7 +39,6 @@ impl ImageGravity { ImageGravity::BottomLeft => "bottom-left", ImageGravity::Bottom => "bottom", ImageGravity::BottomRight => "bottom-right", - ImageGravity::Auto => "auto", } } } diff --git a/src/enums/mod.rs b/src/enums/mod.rs index 91c4db1..607046f 100644 --- a/src/enums/mod.rs +++ b/src/enums/mod.rs @@ -54,8 +54,6 @@ pub mod message_priority; pub use message_priority::MessagePriority; pub mod smtp_encryption; pub use smtp_encryption::SmtpEncryption; -pub mod organization_key_scopes; -pub use organization_key_scopes::OrganizationKeyScopes; pub mod region; pub use region::Region; pub mod project_auth_method_id; @@ -162,6 +160,8 @@ pub mod proxy_rule_deployment_resource_type; pub use proxy_rule_deployment_resource_type::ProxyRuleDeploymentResourceType; pub mod proxy_rule_status; pub use proxy_rule_status::ProxyRuleStatus; +pub mod proxy_rule_protocol; +pub use proxy_rule_protocol::ProxyRuleProtocol; pub mod message_status; pub use message_status::MessageStatus; pub mod billing_plan_group; diff --git a/src/enums/organization_key_scopes.rs b/src/enums/organization_key_scopes.rs deleted file mode 100644 index 7844c9b..0000000 --- a/src/enums/organization_key_scopes.rs +++ /dev/null @@ -1,72 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] -pub enum OrganizationKeyScopes { - #[serde(rename = "projects.read")] - #[default] - ProjectsRead, - #[serde(rename = "projects.write")] - ProjectsWrite, - #[serde(rename = "devKeys.read")] - DevKeysRead, - #[serde(rename = "devKeys.write")] - DevKeysWrite, - #[serde(rename = "organization.keys.read")] - OrganizationKeysRead, - #[serde(rename = "organization.keys.write")] - OrganizationKeysWrite, - #[serde(rename = "organization.installations.read")] - OrganizationInstallationsRead, - #[serde(rename = "organization.installations.write")] - OrganizationInstallationsWrite, - #[serde(rename = "organization.memberships.read")] - OrganizationMembershipsRead, - #[serde(rename = "organization.memberships.write")] - OrganizationMembershipsWrite, - #[serde(rename = "organization.read")] - OrganizationRead, - #[serde(rename = "organization.write")] - OrganizationWrite, - #[serde(rename = "domains.read")] - DomainsRead, - #[serde(rename = "domains.write")] - DomainsWrite, - #[serde(rename = "keys.read")] - KeysRead, - #[serde(rename = "keys.write")] - KeysWrite, -} - -impl OrganizationKeyScopes { - /// Get the string value of the enum - pub fn as_str(&self) -> &str { - match self { - OrganizationKeyScopes::ProjectsRead => "projects.read", - OrganizationKeyScopes::ProjectsWrite => "projects.write", - OrganizationKeyScopes::DevKeysRead => "devKeys.read", - OrganizationKeyScopes::DevKeysWrite => "devKeys.write", - OrganizationKeyScopes::OrganizationKeysRead => "organization.keys.read", - OrganizationKeyScopes::OrganizationKeysWrite => "organization.keys.write", - OrganizationKeyScopes::OrganizationInstallationsRead => { - "organization.installations.read" - } - OrganizationKeyScopes::OrganizationInstallationsWrite => { - "organization.installations.write" - } - OrganizationKeyScopes::OrganizationMembershipsRead => "organization.memberships.read", - OrganizationKeyScopes::OrganizationMembershipsWrite => "organization.memberships.write", - OrganizationKeyScopes::OrganizationRead => "organization.read", - OrganizationKeyScopes::OrganizationWrite => "organization.write", - OrganizationKeyScopes::DomainsRead => "domains.read", - OrganizationKeyScopes::DomainsWrite => "domains.write", - OrganizationKeyScopes::KeysRead => "keys.read", - OrganizationKeyScopes::KeysWrite => "keys.write", - } - } -} - -impl std::fmt::Display for OrganizationKeyScopes { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.as_str()) - } -} diff --git a/src/enums/proxy_rule_protocol.rs b/src/enums/proxy_rule_protocol.rs new file mode 100644 index 0000000..b5ac0d2 --- /dev/null +++ b/src/enums/proxy_rule_protocol.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProxyRuleProtocol { + #[serde(rename = "http")] + #[default] + Http, + #[serde(rename = "smtp")] + Smtp, +} + +impl ProxyRuleProtocol { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProxyRuleProtocol::Http => "http", + ProxyRuleProtocol::Smtp => "smtp", + } + } +} + +impl std::fmt::Display for ProxyRuleProtocol { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/lib.rs b/src/lib.rs index 25914d9..b9f7ed2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```toml //! [dependencies] -//! appwrite = "0.19.0" +//! appwrite = "0.20.0" //! ``` //! //! ## Usage @@ -41,6 +41,7 @@ pub mod operator; pub mod permission; pub mod query; pub mod role; +pub mod topic; // Re-export commonly used types pub use client::Client; @@ -51,7 +52,7 @@ pub use input_file::InputFile; pub type Result = std::result::Result; /// SDK version -pub const VERSION: &str = "0.19.0"; +pub const VERSION: &str = "0.20.0"; /// SDK name pub const SDK_NAME: &str = "Rust"; diff --git a/src/models/activity_event.rs b/src/models/activity_event.rs index 5590142..b488871 100644 --- a/src/models/activity_event.rs +++ b/src/models/activity_event.rs @@ -8,93 +8,238 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEvent { /// Event ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Actor type. #[serde(rename = "actorType")] + #[serde(default = "default_actor_type")] pub actor_type: String, /// Actor ID. #[serde(rename = "actorId")] + #[serde(default = "default_actor_id")] pub actor_id: String, /// Actor Email. #[serde(rename = "actorEmail")] + #[serde(default = "default_actor_email")] pub actor_email: String, /// Actor Name. #[serde(rename = "actorName")] + #[serde(default = "default_actor_name")] pub actor_name: String, /// Resource parent. #[serde(rename = "resourceParent")] + #[serde(default = "default_resource_parent")] pub resource_parent: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource. #[serde(rename = "resource")] + #[serde(default = "default_resource")] pub resource: String, /// Event name. #[serde(rename = "event")] + #[serde(default = "default_event")] pub event: String, /// User agent. #[serde(rename = "userAgent")] + #[serde(default = "default_user_agent")] pub user_agent: String, /// IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// API mode when event triggered. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Location. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// City name. #[serde(rename = "city")] + #[serde(default = "default_city")] pub city: String, /// Region/state chain. #[serde(rename = "subdivisions")] + #[serde(default = "default_subdivisions")] pub subdivisions: String, /// Internet service provider. #[serde(rename = "isp")] + #[serde(default = "default_isp")] pub isp: String, /// Autonomous System Number (ASN). #[serde(rename = "autonomousSystemNumber")] + #[serde(default = "default_autonomous_system_number")] pub autonomous_system_number: String, /// Organization that owns the ASN. #[serde(rename = "autonomousSystemOrganization")] + #[serde(default = "default_autonomous_system_organization")] pub autonomous_system_organization: String, /// Connection type (e.g. cable, cellular, corporate). #[serde(rename = "connectionType")] + #[serde(default = "default_connection_type")] pub connection_type: String, /// User type (e.g. residential, business, hosting). #[serde(rename = "connectionUsageType")] + #[serde(default = "default_connection_usage_type")] pub connection_usage_type: String, /// Registered organization of the IP. #[serde(rename = "connectionOrganization")] + #[serde(default = "default_connection_organization")] pub connection_organization: String, /// Log creation date in ISO 8601 format. #[serde(rename = "time")] + #[serde(default = "default_time")] pub time: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Hostname. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Name of the SDK that triggered the event. #[serde(rename = "sdk")] + #[serde(default = "default_sdk")] pub sdk: String, /// Version of the SDK that triggered the event. #[serde(rename = "sdkVersion")] + #[serde(default = "default_sdk_version")] pub sdk_version: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_actor_type() -> String { + "".to_string() +} + +fn default_actor_id() -> String { + "".to_string() +} + +fn default_actor_email() -> String { + "".to_string() +} + +fn default_actor_name() -> String { + "".to_string() +} + +fn default_resource_parent() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource() -> String { + "".to_string() +} + +fn default_event() -> String { + "".to_string() +} + +fn default_user_agent() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_mode() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_city() -> String { + "".to_string() +} + +fn default_subdivisions() -> String { + "".to_string() +} + +fn default_isp() -> String { + "".to_string() +} + +fn default_autonomous_system_number() -> String { + "".to_string() +} + +fn default_autonomous_system_organization() -> String { + "".to_string() +} + +fn default_connection_type() -> String { + "".to_string() +} + +fn default_connection_usage_type() -> String { + "".to_string() +} + +fn default_connection_organization() -> String { + "".to_string() +} + +fn default_time() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_sdk() -> String { + "".to_string() +} + +fn default_sdk_version() -> String { + "".to_string() +} + impl ActivityEvent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/activity_event_list.rs b/src/models/activity_event_list.rs index a83d557..ff7cf56 100644 --- a/src/models/activity_event_list.rs +++ b/src/models/activity_event_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ActivityEventList { /// Total number of events that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ActivityEventList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/additional_resource.rs b/src/models/additional_resource.rs index bf02523..8f5d252 100644 --- a/src/models/additional_resource.rs +++ b/src/models/additional_resource.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct AdditionalResource { /// Resource name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Resource unit #[serde(rename = "unit")] + #[serde(default = "default_unit")] pub unit: String, /// Price currency #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_unit() -> String { + "".to_string() +} + +fn default_currency() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl AdditionalResource { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/algo_argon2.rs b/src/models/algo_argon2.rs index c4e4c7e..490a220 100644 --- a/src/models/algo_argon2.rs +++ b/src/models/algo_argon2.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoArgon2 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Memory used to compute hash. #[serde(rename = "memoryCost")] + #[serde(default = "default_memory_cost")] pub memory_cost: i64, /// Amount of time consumed to compute hash #[serde(rename = "timeCost")] + #[serde(default = "default_time_cost")] pub time_cost: i64, /// Number of threads used to compute hash. #[serde(rename = "threads")] + #[serde(default = "default_threads")] pub threads: i64, } +fn default_type() -> String { + "argon2".to_string() +} + +fn default_memory_cost() -> i64 { + 0 +} + +fn default_time_cost() -> i64 { + 0 +} + +fn default_threads() -> i64 { + 0 +} + impl AlgoArgon2 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_bcrypt.rs b/src/models/algo_bcrypt.rs index acbd333..93c307f 100644 --- a/src/models/algo_bcrypt.rs +++ b/src/models/algo_bcrypt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoBcrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "bcrypt".to_string() +} + impl AlgoBcrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_md5.rs b/src/models/algo_md5.rs index babd088..3f75ba8 100644 --- a/src/models/algo_md5.rs +++ b/src/models/algo_md5.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoMd5 { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "md5".to_string() +} + impl AlgoMd5 { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_phpass.rs b/src/models/algo_phpass.rs index 8227738..0a9f876 100644 --- a/src/models/algo_phpass.rs +++ b/src/models/algo_phpass.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoPhpass { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "phpass".to_string() +} + impl AlgoPhpass { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt.rs b/src/models/algo_scrypt.rs index 86a424a..18c4bce 100644 --- a/src/models/algo_scrypt.rs +++ b/src/models/algo_scrypt.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScrypt { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// CPU complexity of computed hash. #[serde(rename = "costCpu")] + #[serde(default = "default_cost_cpu")] pub cost_cpu: i64, /// Memory complexity of computed hash. #[serde(rename = "costMemory")] + #[serde(default = "default_cost_memory")] pub cost_memory: i64, /// Parallelization of computed hash. #[serde(rename = "costParallel")] + #[serde(default = "default_cost_parallel")] pub cost_parallel: i64, /// Length used to compute hash. #[serde(rename = "length")] + #[serde(default = "default_length")] pub length: i64, } +fn default_type() -> String { + "scrypt".to_string() +} + +fn default_cost_cpu() -> i64 { + 8 +} + +fn default_cost_memory() -> i64 { + 14 +} + +fn default_cost_parallel() -> i64 { + 1 +} + +fn default_length() -> i64 { + 64 +} + impl AlgoScrypt { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_scrypt_modified.rs b/src/models/algo_scrypt_modified.rs index 3722ebd..35cd10c 100644 --- a/src/models/algo_scrypt_modified.rs +++ b/src/models/algo_scrypt_modified.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct AlgoScryptModified { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Salt used to compute hash. #[serde(rename = "salt")] + #[serde(default = "default_salt")] pub salt: String, /// Separator used to compute hash. #[serde(rename = "saltSeparator")] + #[serde(default = "default_salt_separator")] pub salt_separator: String, /// Key used to compute hash. #[serde(rename = "signerKey")] + #[serde(default = "default_signer_key")] pub signer_key: String, } +fn default_type() -> String { + "scryptMod".to_string() +} + +fn default_salt() -> String { + "".to_string() +} + +fn default_salt_separator() -> String { + "".to_string() +} + +fn default_signer_key() -> String { + "".to_string() +} + impl AlgoScryptModified { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/algo_sha.rs b/src/models/algo_sha.rs index e8aa8fb..f3af46d 100644 --- a/src/models/algo_sha.rs +++ b/src/models/algo_sha.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct AlgoSha { /// Algo type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_type() -> String { + "sha".to_string() +} + impl AlgoSha { /// Get r#type pub fn r#type(&self) -> &String { diff --git a/src/models/app.rs b/src/models/app.rs index 35791b2..3ed9196 100644 --- a/src/models/app.rs +++ b/src/models/app.rs @@ -8,95 +8,225 @@ use serde::{Deserialize, Serialize}; pub struct App { /// App ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Application description shown to users during OAuth2 consent. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Application homepage URL shown to users during OAuth2 consent. #[serde(rename = "clientUri")] + #[serde(default = "default_client_uri")] pub client_uri: String, /// Application logo URL shown to users during OAuth2 consent. #[serde(rename = "logoUri")] + #[serde(default = "default_logo_uri")] pub logo_uri: String, /// Application privacy policy URL shown to users during OAuth2 consent. #[serde(rename = "privacyPolicyUrl")] + #[serde(default = "default_privacy_policy_url")] pub privacy_policy_url: String, /// Application terms of service URL shown to users during OAuth2 consent. #[serde(rename = "termsUrl")] + #[serde(default = "default_terms_url")] pub terms_url: String, /// Application support or security contact emails. #[serde(rename = "contacts")] + #[serde(default = "default_contacts")] pub contacts: Vec, /// Application tagline shown to users during OAuth2 consent. #[serde(rename = "tagline")] + #[serde(default = "default_tagline")] pub tagline: String, /// Application tags shown to users during OAuth2 consent. #[serde(rename = "tags")] + #[serde(default = "default_tags")] pub tags: Vec, /// Application labels. Read-only for clients; only a server SDK using a /// project API key can update them. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Application image URLs shown to users during OAuth2 consent. #[serde(rename = "images")] + #[serde(default = "default_images")] pub images: Vec, /// Application support URL shown to users during OAuth2 consent. #[serde(rename = "supportUrl")] + #[serde(default = "default_support_url")] pub support_url: String, /// Application data deletion URL shown to users during OAuth2 consent. #[serde(rename = "dataDeletionUrl")] + #[serde(default = "default_data_deletion_url")] pub data_deletion_url: String, /// List of authorized redirect URIs. These URIs can be used to redirect users /// after they authenticate. #[serde(rename = "redirectUris")] + #[serde(default = "default_redirect_uris")] pub redirect_uris: Vec, /// List of authorized post-logout redirect URIs for OpenID Connect /// RP-Initiated Logout. The logout endpoint only redirects users to URIs in /// this list after ending their session. #[serde(rename = "postLogoutRedirectUris")] + #[serde(default = "default_post_logout_redirect_uris")] pub post_logout_redirect_uris: Vec, /// Whether the app is enabled or not. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot /// keep a client secret (PKCE required); `confidential` for server-side /// clients that authenticate with a client secret. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Whether this client may use the OAuth2 Device Authorization Grant (RFC /// 8628). #[serde(rename = "deviceFlow")] + #[serde(default = "default_device_flow")] pub device_flow: bool, /// ID of team that owns the application, if owned by team. Otherwise, user ID /// will be used. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// ID of user who owns the application, if owned by user. Otherwise, team ID /// will be used. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Scopes the application requests when installed on a team. /// Organization-level and project-level scopes only. #[serde(rename = "installationScopes")] + #[serde(default = "default_installation_scopes")] pub installation_scopes: Vec, /// URL users are redirected to after creating or updating an installation of /// this application. Empty for no redirect. #[serde(rename = "installationRedirectUrl")] + #[serde(default = "default_installation_redirect_url")] pub installation_redirect_url: String, /// List of application secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_client_uri() -> String { + "".to_string() +} + +fn default_logo_uri() -> String { + "".to_string() +} + +fn default_privacy_policy_url() -> String { + "".to_string() +} + +fn default_terms_url() -> String { + "".to_string() +} + +fn default_contacts() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tagline() -> String { + "".to_string() +} + +fn default_tags() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_images() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_support_url() -> String { + "".to_string() +} + +fn default_data_deletion_url() -> String { + "".to_string() +} + +fn default_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_post_logout_redirect_uris() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "confidential".to_string() +} + +fn default_device_flow() -> bool { + false +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_installation_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_installation_redirect_url() -> String { + "".to_string() +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl App { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation.rs b/src/models/app_installation.rs index 7ad4193..970ba93 100644 --- a/src/models/app_installation.rs +++ b/src/models/app_installation.rs @@ -8,34 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallation { /// Installation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Installation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Installation update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the installed application. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// ID of the team the application is installed on. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Scopes granted to the application. Snapshot of the application's /// installation scopes taken when the installation was created or last /// updated. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Authorization details granted to the application. Rich authorization /// request (RFC 9396) style entries; the Appwrite Console stores authorized /// project IDs here. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: Vec, /// ID of the user who created the installation. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the installation. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time an access token was last issued for the installation in ISO 8601 /// format. Null if never used. @@ -44,6 +53,42 @@ pub struct AppInstallation { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppInstallation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_installation_list.rs b/src/models/app_installation_list.rs index aa427f0..69c156a 100644 --- a/src/models/app_installation_list.rs +++ b/src/models/app_installation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppInstallationList { /// Total number of installations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of installations. #[serde(rename = "installations")] + #[serde(default = "default_installations")] pub installations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_installations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppInstallationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_key.rs b/src/models/app_key.rs index cbfbbd0..4902670 100644 --- a/src/models/app_key.rs +++ b/src/models/app_key.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct AppKey { /// App key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// App key creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// App key update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this app key belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// App key secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the app key secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the app key. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the app key. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the app key was last used for authentication in ISO 8601 format. Null /// if never used. @@ -37,6 +45,38 @@ pub struct AppKey { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_key_list.rs b/src/models/app_key_list.rs index 232fa6f..d9ca8bb 100644 --- a/src/models/app_key_list.rs +++ b/src/models/app_key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppKeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppKeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_scope.rs b/src/models/app_scope.rs index 7f14082..fcdf744 100644 --- a/src/models/app_scope.rs +++ b/src/models/app_scope.rs @@ -8,23 +8,48 @@ use serde::{Deserialize, Serialize}; pub struct AppScope { /// Scope value as requested by apps. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Human-readable description of what the scope grants. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// What the scope grants access to. One of `account`, `project`, or /// `organization`. Only `project` and `organization` scopes are installable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Scope category, used to group scopes on consent and installation screens. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, /// Whether the scope is deprecated. Deprecated scopes can still be requested /// but should not be offered for new grants. #[serde(rename = "deprecated")] + #[serde(default = "default_deprecated")] pub deprecated: bool, } +fn default_value() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + +fn default_deprecated() -> bool { + false +} + impl AppScope { /// Get value pub fn value(&self) -> &String { diff --git a/src/models/app_scope_list.rs b/src/models/app_scope_list.rs index 0d93b62..cd03802 100644 --- a/src/models/app_scope_list.rs +++ b/src/models/app_scope_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppScopeList { /// Total number of scopes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppScopeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret.rs b/src/models/app_secret.rs index a32282b..43fd6cd 100644 --- a/src/models/app_secret.rs +++ b/src/models/app_secret.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecret { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Always empty. The application client secret is returned only once, in the /// response of the createSecret method. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecret { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/app_secret_list.rs b/src/models/app_secret_list.rs index f9df34d..23dcef0 100644 --- a/src/models/app_secret_list.rs +++ b/src/models/app_secret_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretList { /// Total number of secrets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of secrets. #[serde(rename = "secrets")] + #[serde(default = "default_secrets")] pub secrets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_secrets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppSecretList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/app_secret_plaintext.rs b/src/models/app_secret_plaintext.rs index 4c7a292..486d526 100644 --- a/src/models/app_secret_plaintext.rs +++ b/src/models/app_secret_plaintext.rs @@ -8,28 +8,36 @@ use serde::{Deserialize, Serialize}; pub struct AppSecretPlaintext { /// Secret ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Secret creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Secret update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Application ID this secret belongs to. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Application client secret. Returned only when the secret is created; /// subsequent reads always return an empty value. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Last few characters of the client secret, used to help identify it. #[serde(rename = "hint")] + #[serde(default = "default_hint")] pub hint: String, /// ID of the user who created the secret. #[serde(rename = "createdById")] + #[serde(default = "default_created_by_id")] pub created_by_id: String, /// Name of the user who created the secret. #[serde(rename = "createdByName")] + #[serde(default = "default_created_by_name")] pub created_by_name: String, /// Time the secret was last used for authentication in ISO 8601 format. Null /// if never used. @@ -38,6 +46,38 @@ pub struct AppSecretPlaintext { pub last_accessed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_hint() -> String { + "".to_string() +} + +fn default_created_by_id() -> String { + "".to_string() +} + +fn default_created_by_name() -> String { + "".to_string() +} + impl AppSecretPlaintext { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/apps_list.rs b/src/models/apps_list.rs index 6f31208..b8c106d 100644 --- a/src/models/apps_list.rs +++ b/src/models/apps_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AppsList { /// Total number of apps that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of apps. #[serde(rename = "apps")] + #[serde(default = "default_apps")] pub apps: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_apps() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AppsList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_bigint.rs b/src/models/attribute_bigint.rs index 7dffebc..9f298a7 100644 --- a/src/models/attribute_bigint.rs +++ b/src/models/attribute_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBigint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBigint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBigint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_boolean.rs b/src/models/attribute_boolean.rs index e6ddcc3..e08baa3 100644 --- a/src/models/attribute_boolean.rs +++ b/src/models/attribute_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeBoolean { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeBoolean { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_datetime.rs b/src/models/attribute_datetime.rs index beacd6d..79621c2 100644 --- a/src/models/attribute_datetime.rs +++ b/src/models/attribute_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeDatetime { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeDatetime { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct AttributeDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_email.rs b/src/models/attribute_email.rs index 2f172f7..76dcae3 100644 --- a/src/models/attribute_email.rs +++ b/src/models/attribute_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEmail { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEmail { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeEmail { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl AttributeEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_enum.rs b/src/models/attribute_enum.rs index f78d0eb..620db3a 100644 --- a/src/models/attribute_enum.rs +++ b/src/models/attribute_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeEnum { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeEnum { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct AttributeEnum { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -46,6 +54,38 @@ pub struct AttributeEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl AttributeEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_float.rs b/src/models/attribute_float.rs index 49cda73..a8467e7 100644 --- a/src/models/attribute_float.rs +++ b/src/models/attribute_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeFloat { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeFloat { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeFloat { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_integer.rs b/src/models/attribute_integer.rs index 39cad56..abb02d0 100644 --- a/src/models/attribute_integer.rs +++ b/src/models/attribute_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeInteger { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeInteger { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeInteger { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct AttributeInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_ip.rs b/src/models/attribute_ip.rs index 2328c38..85c4070 100644 --- a/src/models/attribute_ip.rs +++ b/src/models/attribute_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeIp { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeIp { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeIp { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl AttributeIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_line.rs b/src/models/attribute_line.rs index 975994b..670484f 100644 --- a/src/models/attribute_line.rs +++ b/src/models/attribute_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLine { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLine { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLine { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributeLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_list.rs b/src/models/attribute_list.rs index d405e6d..73e9346 100644 --- a/src/models/attribute_list.rs +++ b/src/models/attribute_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct AttributeList { /// Total number of attributes in the given collection. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl AttributeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/attribute_longtext.rs b/src/models/attribute_longtext.rs index b613bf1..a45a044 100644 --- a/src/models/attribute_longtext.rs +++ b/src/models/attribute_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeLongtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeLongtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_mediumtext.rs b/src/models/attribute_mediumtext.rs index 98fcecd..18271f2 100644 --- a/src/models/attribute_mediumtext.rs +++ b/src/models/attribute_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeMediumtext { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeMediumtext { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_object.rs b/src/models/attribute_object.rs index 02515bf..ce3af14 100644 --- a/src/models/attribute_object.rs +++ b/src/models/attribute_object.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeObject { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeObject { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,38 @@ pub struct AttributeObject { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeObject { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_point.rs b/src/models/attribute_point.rs index 9ca02a2..d9284e1 100644 --- a/src/models/attribute_point.rs +++ b/src/models/attribute_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePoint { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePoint { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePoint { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_polygon.rs b/src/models/attribute_polygon.rs index 3d39979..59a058b 100644 --- a/src/models/attribute_polygon.rs +++ b/src/models/attribute_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributePolygon { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributePolygon { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributePolygon { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -40,6 +46,30 @@ pub struct AttributePolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributePolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_relationship.rs b/src/models/attribute_relationship.rs index ce0efaf..17b1786 100644 --- a/src/models/attribute_relationship.rs +++ b/src/models/attribute_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeRelationship { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct AttributeRelationship { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related collection. #[serde(rename = "relatedCollection")] pub related_collection: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl AttributeRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_string.rs b/src/models/attribute_string.rs index 93dc8bc..eacad88 100644 --- a/src/models/attribute_string.rs +++ b/src/models/attribute_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeString { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeString { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeString { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_text.rs b/src/models/attribute_text.rs index 838d477..bf666ea 100644 --- a/src/models/attribute_text.rs +++ b/src/models/attribute_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeText { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeText { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct AttributeText { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -44,6 +50,30 @@ pub struct AttributeText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl AttributeText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_url.rs b/src/models/attribute_url.rs index 4dfc86c..2305191 100644 --- a/src/models/attribute_url.rs +++ b/src/models/attribute_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeUrl { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeUrl { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeUrl { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -43,6 +50,34 @@ pub struct AttributeUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl AttributeUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_varchar.rs b/src/models/attribute_varchar.rs index 433fc29..a3277a9 100644 --- a/src/models/attribute_varchar.rs +++ b/src/models/attribute_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVarchar { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct AttributeVarchar { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Attribute size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for attribute when not provided. Cannot be set when attribute /// is required. @@ -47,6 +54,34 @@ pub struct AttributeVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/attribute_vector.rs b/src/models/attribute_vector.rs index 2472da9..79dc1c8 100644 --- a/src/models/attribute_vector.rs +++ b/src/models/attribute_vector.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct AttributeVector { /// Attribute Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Attribute type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Attribute status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct AttributeVector { /// Error message. Displays error generated on failure of creating or deleting /// an attribute. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is attribute required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is attribute an array? #[serde(rename = "array")] @@ -29,15 +33,46 @@ pub struct AttributeVector { pub array: Option, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Vector dimensions. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl AttributeVector { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/backup_archive.rs b/src/models/backup_archive.rs index f4811a5..d64dce1 100644 --- a/src/models/backup_archive.rs +++ b/src/models/backup_archive.rs @@ -8,34 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchive { /// Archive ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Archive creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Archive update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Archive policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, - /// Archive size in bytes. + /// Archive size in bytes. Null until the size is known. #[serde(rename = "size")] - pub size: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, /// The status of the archive creation. Possible values: pending, processing, /// uploading, completed, failed, skipped. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The backup start time. Null until the backup starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this archive. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this archive. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this archive should backup a single /// resource. @@ -49,6 +59,38 @@ pub struct BackupArchive { pub resource_type: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchive { /// Get id pub fn id(&self) -> &String { @@ -70,9 +112,15 @@ impl BackupArchive { &self.policy_id } + /// Set size + pub fn set_size(mut self, size: i64) -> Self { + self.size = Some(size); + self + } + /// Get size - pub fn size(&self) -> &i64 { - &self.size + pub fn size(&self) -> Option<&i64> { + self.size.as_ref() } /// Get status @@ -80,9 +128,15 @@ impl BackupArchive { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -134,9 +188,7 @@ mod tests { let _ = _model.created_at(); let _ = _model.updated_at(); let _ = _model.policy_id(); - let _ = _model.size(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_archive_list.rs b/src/models/backup_archive_list.rs index 46af024..6c12aea 100644 --- a/src/models/backup_archive_list.rs +++ b/src/models/backup_archive_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupArchiveList { /// Total number of archives that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of archives. #[serde(rename = "archives")] + #[serde(default = "default_archives")] pub archives: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_archives() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupArchiveList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_policy.rs b/src/models/backup_policy.rs index 0ee8535..5c2c5a7 100644 --- a/src/models/backup_policy.rs +++ b/src/models/backup_policy.rs @@ -8,21 +8,27 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicy { /// Backup policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup policy name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Policy creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Policy update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// The resource ID to backup. Set only if this policy should backup a single /// resource. @@ -36,19 +42,63 @@ pub struct BackupPolicy { pub resource_type: Option, /// How many days to keep the backup before it will be automatically deleted. #[serde(rename = "retention")] + #[serde(default = "default_retention")] pub retention: i64, /// Policy backup schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Is this policy enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_retention() -> i64 { + 1 +} + +fn default_schedule() -> String { + "0 * * * *".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_enabled() -> bool { + false +} + impl BackupPolicy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/backup_policy_list.rs b/src/models/backup_policy_list.rs index 299f36b..60a4ad3 100644 --- a/src/models/backup_policy_list.rs +++ b/src/models/backup_policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupPolicyList { /// Total number of policies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupPolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/backup_restoration.rs b/src/models/backup_restoration.rs index 45931ed..2dc302b 100644 --- a/src/models/backup_restoration.rs +++ b/src/models/backup_restoration.rs @@ -8,38 +8,89 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Restoration update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Backup archive ID. #[serde(rename = "archiveId")] + #[serde(default = "default_archive_id")] pub archive_id: String, /// Backup policy ID. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// The status of the restoration. Possible values: pending, downloading, /// processing, completed, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// The backup start time. + /// The restoration start time. Null until the restoration starts. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Migration ID. #[serde(rename = "migrationId")] + #[serde(default = "default_migration_id")] pub migration_id: String, /// The services that are backed up by this policy. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// The resources that are backed up by this policy. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, - /// Optional data in key-value object. + /// Restoration options as a key-value object. #[serde(rename = "options")] - pub options: String, + #[serde(default = "default_options")] + pub options: serde_json::Value, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_archive_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_migration_id() -> String { + "".to_string() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_options() -> serde_json::Value { + serde_json::json!({}) } impl BackupRestoration { @@ -73,9 +124,15 @@ impl BackupRestoration { &self.status } + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() } /// Get migration_id @@ -94,7 +151,7 @@ impl BackupRestoration { } /// Get options - pub fn options(&self) -> &String { + pub fn options(&self) -> &serde_json::Value { &self.options } } @@ -112,7 +169,6 @@ mod tests { let _ = _model.archive_id(); let _ = _model.policy_id(); let _ = _model.status(); - let _ = _model.started_at(); let _ = _model.migration_id(); let _ = _model.services(); let _ = _model.resources(); diff --git a/src/models/backup_restoration_list.rs b/src/models/backup_restoration_list.rs index 65c9ad3..33d4196 100644 --- a/src/models/backup_restoration_list.rs +++ b/src/models/backup_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BackupRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BackupRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/billing_plan.rs b/src/models/billing_plan.rs index 936f3d8..1e43f95 100644 --- a/src/models/billing_plan.rs +++ b/src/models/billing_plan.rs @@ -8,33 +8,43 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlan { /// Plan ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Plan name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Plan description #[serde(rename = "desc")] + #[serde(default = "default_desc")] pub desc: String, /// Plan order #[serde(rename = "order")] + #[serde(default = "default_order")] pub order: i64, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Trial days #[serde(rename = "trial")] + #[serde(default = "default_trial")] pub trial: i64, /// Bandwidth #[serde(rename = "bandwidth")] + #[serde(default = "default_bandwidth")] pub bandwidth: i64, /// Storage #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Image Transformations #[serde(rename = "imageTransformations")] + #[serde(default = "default_image_transformations")] pub image_transformations: i64, /// Screenshots generated #[serde(rename = "screenshotsGenerated")] + #[serde(default = "default_screenshots_generated")] pub screenshots_generated: i64, /// Members #[serde(rename = "members")] @@ -42,77 +52,100 @@ pub struct BillingPlan { pub members: Option, /// Webhooks #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: i64, /// Maximum WAF rules per project #[serde(rename = "wafRules")] + #[serde(default = "default_waf_rules")] pub waf_rules: i64, /// Maximum environments per project. 0 when the plan does not offer /// environments. #[serde(rename = "environments")] - #[serde(skip_serializing_if = "Option::is_none")] - pub environments: Option, + #[serde(default = "default_environments")] + pub environments: i64, /// Projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: i64, /// Platforms #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: i64, /// Users #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: i64, /// Teams #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: i64, /// Databases #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: i64, /// Database reads per month #[serde(rename = "databasesReads")] + #[serde(default = "default_databases_reads")] pub databases_reads: i64, /// Database writes per month #[serde(rename = "databasesWrites")] + #[serde(default = "default_databases_writes")] pub databases_writes: i64, /// Database batch size limit #[serde(rename = "databasesBatchSize")] + #[serde(default = "default_databases_batch_size")] pub databases_batch_size: i64, /// Buckets #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: i64, /// File size #[serde(rename = "fileSize")] + #[serde(default = "default_file_size")] pub file_size: i64, /// Functions #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: i64, /// Sites #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: i64, /// Function executions #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: i64, /// Rolling max executions retained per function/site #[serde(rename = "executionsRetentionCount")] + #[serde(default = "default_executions_retention_count")] pub executions_retention_count: i64, /// GB hours for functions #[serde(rename = "GBHours")] + #[serde(default = "default_gb_hours")] pub gb_hours: i64, /// Realtime connections #[serde(rename = "realtime")] + #[serde(default = "default_realtime")] pub realtime: i64, /// Realtime messages #[serde(rename = "realtimeMessages")] + #[serde(default = "default_realtime_messages")] pub realtime_messages: i64, /// Messages per month #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: i64, /// Topics for messaging #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: i64, /// SMS authentications per month #[serde(rename = "authPhone")] + #[serde(default = "default_auth_phone")] pub auth_phone: i64, /// Custom domains #[serde(rename = "domains")] + #[serde(default = "default_domains")] pub domains: i64, /// Activity log days #[serde(rename = "activityLogs")] @@ -120,6 +153,7 @@ pub struct BillingPlan { pub activity_logs: Option, /// Usage history days #[serde(rename = "usageLogs")] + #[serde(default = "default_usage_logs")] pub usage_logs: i64, /// Usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). #[serde(rename = "usageLogsIntervals")] @@ -134,30 +168,38 @@ pub struct BillingPlan { /// Number of days of console inactivity before a project is paused. 0 means /// pausing is disabled. #[serde(rename = "projectInactivityDays")] + #[serde(default = "default_project_inactivity_days")] pub project_inactivity_days: i64, /// Alert threshold percentage #[serde(rename = "alertLimit")] + #[serde(default = "default_alert_limit")] pub alert_limit: i64, - /// Additional resources + /// Additional resources. Null when the plan does not support usage billing. #[serde(rename = "usage")] - pub usage: crate::models::UsageBillingPlan, + #[serde(skip_serializing_if = "Option::is_none")] + pub usage: Option, /// Addons #[serde(rename = "addons")] pub addons: crate::models::BillingPlanAddon, /// Budget cap enabled or disabled. #[serde(rename = "budgetCapEnabled")] + #[serde(default = "default_budget_cap_enabled")] pub budget_cap_enabled: bool, /// Custom SMTP #[serde(rename = "customSmtp")] + #[serde(default = "default_custom_smtp")] pub custom_smtp: bool, /// Appwrite branding in email #[serde(rename = "emailBranding")] + #[serde(default = "default_email_branding")] pub email_branding: bool, /// Does plan require payment method #[serde(rename = "requiresPaymentMethod")] + #[serde(default = "default_requires_payment_method")] pub requires_payment_method: bool, /// Does plan require billing address #[serde(rename = "requiresBillingAddress")] + #[serde(default = "default_requires_billing_address")] pub requires_billing_address: bool, /// ISO country codes eligible for this regional plan. Empty means no /// restriction. @@ -166,42 +208,55 @@ pub struct BillingPlan { pub eligible_countries: Option>, /// Is the billing plan available #[serde(rename = "isAvailable")] + #[serde(default = "default_is_available")] pub is_available: bool, /// Can user change the plan themselves #[serde(rename = "selfService")] + #[serde(default = "default_self_service")] pub self_service: bool, /// Does plan enable premium support #[serde(rename = "premiumSupport")] + #[serde(default = "default_premium_support")] pub premium_support: bool, /// Does plan support budget cap #[serde(rename = "budgeting")] + #[serde(default = "default_budgeting")] pub budgeting: bool, /// Does plan support mock numbers #[serde(rename = "supportsMockNumbers")] + #[serde(default = "default_supports_mock_numbers")] pub supports_mock_numbers: bool, /// Does plan support organization roles #[serde(rename = "supportsOrganizationRoles")] + #[serde(default = "default_supports_organization_roles")] pub supports_organization_roles: bool, /// Does plan support credit #[serde(rename = "supportsCredits")] + #[serde(default = "default_supports_credits")] pub supports_credits: bool, /// Does plan support dedicated databases. #[serde(rename = "supportsDedicatedDatabases")] + #[serde(default = "default_supports_dedicated_databases")] pub supports_dedicated_databases: bool, /// Does plan support blocking disposable email addresses. #[serde(rename = "supportsDisposableEmailValidation")] + #[serde(default = "default_supports_disposable_email_validation")] pub supports_disposable_email_validation: bool, /// Does plan support requiring canonical email addresses. #[serde(rename = "supportsCanonicalEmailValidation")] + #[serde(default = "default_supports_canonical_email_validation")] pub supports_canonical_email_validation: bool, /// Does plan support blocking free email addresses. #[serde(rename = "supportsFreeEmailValidation")] + #[serde(default = "default_supports_free_email_validation")] pub supports_free_email_validation: bool, /// Does plan support restricting sign-ups to corporate email addresses only. #[serde(rename = "supportsCorporateEmailValidation")] + #[serde(default = "default_supports_corporate_email_validation")] pub supports_corporate_email_validation: bool, /// Does plan support project-specific member roles. #[serde(rename = "supportsProjectSpecificRoles")] + #[serde(default = "default_supports_project_specific_roles")] pub supports_project_specific_roles: bool, /// Does plan support backup policies. #[serde(rename = "backupsEnabled")] @@ -209,6 +264,7 @@ pub struct BillingPlan { pub backups_enabled: Option, /// Whether usage addons are calculated per project. #[serde(rename = "usagePerProject")] + #[serde(default = "default_usage_per_project")] pub usage_per_project: bool, /// Supported addons for this plan #[serde(rename = "supportedAddons")] @@ -219,16 +275,20 @@ pub struct BillingPlan { pub backup_policies: Option, /// Maximum function and site deployment size in MB #[serde(rename = "deploymentSize")] + #[serde(default = "default_deployment_size")] pub deployment_size: i64, /// Maximum function and site deployment size in MB #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// Shortest function schedule interval allowed, in minutes. 0 allows every /// interval. #[serde(rename = "functionsIntervalMinimum")] + #[serde(default = "default_functions_interval_minimum")] pub functions_interval_minimum: i64, /// Does the plan support encrypted string attributes or not. #[serde(rename = "databasesAllowEncrypt")] + #[serde(default = "default_databases_allow_encrypt")] pub databases_allow_encrypt: bool, /// Plan specific limits #[serde(rename = "limits")] @@ -244,6 +304,7 @@ pub struct BillingPlan { /// Included monthly dedicated-database compute credit in USD. Resets each /// billing cycle with no roll-over. #[serde(rename = "databaseComputeCredit")] + #[serde(default = "default_database_compute_credit")] pub database_compute_credit: f64, /// Dedicated database limits available to this plan. #[serde(rename = "dedicatedDatabases")] @@ -251,6 +312,250 @@ pub struct BillingPlan { pub dedicated_databases: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_desc() -> String { + "".to_string() +} + +fn default_order() -> i64 { + 0 +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_trial() -> i64 { + 0 +} + +fn default_bandwidth() -> i64 { + 0 +} + +fn default_storage() -> i64 { + 0 +} + +fn default_image_transformations() -> i64 { + 0 +} + +fn default_screenshots_generated() -> i64 { + 0 +} + +fn default_webhooks() -> i64 { + 0 +} + +fn default_waf_rules() -> i64 { + 0 +} + +fn default_environments() -> i64 { + 0 +} + +fn default_projects() -> i64 { + 0 +} + +fn default_platforms() -> i64 { + 0 +} + +fn default_users() -> i64 { + 0 +} + +fn default_teams() -> i64 { + 0 +} + +fn default_databases() -> i64 { + 0 +} + +fn default_databases_reads() -> i64 { + 0 +} + +fn default_databases_writes() -> i64 { + 0 +} + +fn default_databases_batch_size() -> i64 { + 0 +} + +fn default_buckets() -> i64 { + 0 +} + +fn default_file_size() -> i64 { + 0 +} + +fn default_functions() -> i64 { + 0 +} + +fn default_sites() -> i64 { + 0 +} + +fn default_executions() -> i64 { + 0 +} + +fn default_executions_retention_count() -> i64 { + 1000 +} + +fn default_gb_hours() -> i64 { + 0 +} + +fn default_realtime() -> i64 { + 0 +} + +fn default_realtime_messages() -> i64 { + 0 +} + +fn default_messages() -> i64 { + 0 +} + +fn default_topics() -> i64 { + 0 +} + +fn default_auth_phone() -> i64 { + 0 +} + +fn default_domains() -> i64 { + 0 +} + +fn default_usage_logs() -> i64 { + 0 +} + +fn default_project_inactivity_days() -> i64 { + 0 +} + +fn default_alert_limit() -> i64 { + 80 +} + +fn default_budget_cap_enabled() -> bool { + false +} + +fn default_custom_smtp() -> bool { + false +} + +fn default_email_branding() -> bool { + false +} + +fn default_requires_payment_method() -> bool { + true +} + +fn default_requires_billing_address() -> bool { + false +} + +fn default_is_available() -> bool { + true +} + +fn default_self_service() -> bool { + true +} + +fn default_premium_support() -> bool { + true +} + +fn default_budgeting() -> bool { + true +} + +fn default_supports_mock_numbers() -> bool { + true +} + +fn default_supports_organization_roles() -> bool { + true +} + +fn default_supports_credits() -> bool { + false +} + +fn default_supports_dedicated_databases() -> bool { + false +} + +fn default_supports_disposable_email_validation() -> bool { + false +} + +fn default_supports_canonical_email_validation() -> bool { + false +} + +fn default_supports_free_email_validation() -> bool { + false +} + +fn default_supports_corporate_email_validation() -> bool { + false +} + +fn default_supports_project_specific_roles() -> bool { + false +} + +fn default_usage_per_project() -> bool { + true +} + +fn default_deployment_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_functions_interval_minimum() -> i64 { + 0 +} + +fn default_databases_allow_encrypt() -> bool { + false +} + +fn default_database_compute_credit() -> f64 { + 0.0 +} + impl BillingPlan { /// Get id pub fn id(&self) -> &String { @@ -323,15 +628,9 @@ impl BillingPlan { &self.waf_rules } - /// Set environments - pub fn set_environments(mut self, environments: i64) -> Self { - self.environments = Some(environments); - self - } - /// Get environments - pub fn environments(&self) -> Option<&i64> { - self.environments.as_ref() + pub fn environments(&self) -> &i64 { + &self.environments } /// Get projects @@ -490,9 +789,15 @@ impl BillingPlan { &self.alert_limit } + /// Set usage + pub fn set_usage(mut self, usage: crate::models::UsageBillingPlan) -> Self { + self.usage = Some(usage); + self + } + /// Get usage - pub fn usage(&self) -> &crate::models::UsageBillingPlan { - &self.usage + pub fn usage(&self) -> Option<&crate::models::UsageBillingPlan> { + self.usage.as_ref() } /// Get addons @@ -721,6 +1026,7 @@ mod tests { let _ = _model.screenshots_generated(); let _ = _model.webhooks(); let _ = _model.waf_rules(); + let _ = _model.environments(); let _ = _model.projects(); let _ = _model.platforms(); let _ = _model.users(); @@ -745,7 +1051,6 @@ mod tests { let _ = _model.usage_logs(); let _ = _model.project_inactivity_days(); let _ = _model.alert_limit(); - let _ = _model.usage(); let _ = _model.addons(); let _ = _model.budget_cap_enabled(); let _ = _model.custom_smtp(); diff --git a/src/models/billing_plan_addon_details.rs b/src/models/billing_plan_addon_details.rs index 00aa018..3557b0d 100644 --- a/src/models/billing_plan_addon_details.rs +++ b/src/models/billing_plan_addon_details.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanAddonDetails { /// Is the addon supported in the plan? #[serde(rename = "supported")] + #[serde(default = "default_supported")] pub supported: bool, /// Addon plan included value #[serde(rename = "planIncluded")] + #[serde(default = "default_plan_included")] pub plan_included: i64, /// Addon limit #[serde(rename = "limit")] + #[serde(default = "default_limit")] pub limit: i64, /// Addon type #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Price currency #[serde(rename = "currency")] @@ -24,15 +28,46 @@ pub struct BillingPlanAddonDetails { pub currency: Option, /// Price #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Resource value #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: i64, /// Description on invoice #[serde(rename = "invoiceDesc")] + #[serde(default = "default_invoice_desc")] pub invoice_desc: String, } +fn default_supported() -> bool { + false +} + +fn default_plan_included() -> i64 { + 0 +} + +fn default_limit() -> i64 { + 0 +} + +fn default_type() -> String { + "numeric".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_value() -> i64 { + 0 +} + +fn default_invoice_desc() -> String { + "".to_string() +} + impl BillingPlanAddonDetails { /// Get supported pub fn supported(&self) -> &bool { diff --git a/src/models/billing_plan_supported_addons.rs b/src/models/billing_plan_supported_addons.rs index af95b2d..74f7ee1 100644 --- a/src/models/billing_plan_supported_addons.rs +++ b/src/models/billing_plan_supported_addons.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct BillingPlanSupportedAddons { /// Whether the plan supports BAA (Business Associate Agreement) addon #[serde(rename = "baa")] + #[serde(default = "default_baa")] pub baa: bool, /// Whether the plan supports Premium Geo DB addon (project-level) #[serde(rename = "premiumGeoDB")] + #[serde(default = "default_premium_geo_db")] pub premium_geo_db: bool, /// Whether the plan supports Premium Geo DB addon (organization-level) #[serde(rename = "premiumGeoDBOrg")] + #[serde(default = "default_premium_geo_db_org")] pub premium_geo_db_org: bool, } +fn default_baa() -> bool { + false +} + +fn default_premium_geo_db() -> bool { + false +} + +fn default_premium_geo_db_org() -> bool { + false +} + impl BillingPlanSupportedAddons { /// Get baa pub fn baa(&self) -> &bool { diff --git a/src/models/block.rs b/src/models/block.rs index 9bd4591..8af751d 100644 --- a/src/models/block.rs +++ b/src/models/block.rs @@ -8,40 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct Block { /// Block creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource type that is blocked #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Resource identifier that is blocked #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Block mode. full blocks reads and writes; readOnly blocks writes only. #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, - /// Reason for the block. Can be null if no reason was provided. - #[serde(rename = "reason")] - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// Block expiration date in ISO 8601 format. Can be null if the block does not /// expire. #[serde(rename = "expiredAt")] #[serde(skip_serializing_if = "Option::is_none")] pub expired_at: Option, - /// Name of the project this block applies to. - #[serde(rename = "projectName")] - pub project_name: String, - /// Region of the project this block applies to. - #[serde(rename = "region")] - pub region: String, - /// Name of the organization that owns the project. - #[serde(rename = "organizationName")] - pub organization_name: String, - /// ID of the organization that owns the project. - #[serde(rename = "organizationId")] - pub organization_id: String, - /// Billing plan of the organization that owns the project. - #[serde(rename = "billingPlan")] - pub billing_plan: String, +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_mode() -> String { + "full".to_string() } impl Block { @@ -65,17 +66,6 @@ impl Block { &self.mode } - /// Set reason - pub fn set_reason(mut self, reason: String) -> Self { - self.reason = Some(reason); - self - } - - /// Get reason - pub fn reason(&self) -> Option<&String> { - self.reason.as_ref() - } - /// Set expired_at pub fn set_expired_at(mut self, expired_at: String) -> Self { self.expired_at = Some(expired_at); @@ -86,31 +76,6 @@ impl Block { pub fn expired_at(&self) -> Option<&String> { self.expired_at.as_ref() } - - /// Get project_name - pub fn project_name(&self) -> &String { - &self.project_name - } - - /// Get region - pub fn region(&self) -> &String { - &self.region - } - - /// Get organization_name - pub fn organization_name(&self) -> &String { - &self.organization_name - } - - /// Get organization_id - pub fn organization_id(&self) -> &String { - &self.organization_id - } - - /// Get billing_plan - pub fn billing_plan(&self) -> &String { - &self.billing_plan - } } #[cfg(test)] @@ -124,11 +89,6 @@ mod tests { let _ = _model.resource_type(); let _ = _model.resource_id(); let _ = _model.mode(); - let _ = _model.project_name(); - let _ = _model.region(); - let _ = _model.organization_name(); - let _ = _model.organization_id(); - let _ = _model.billing_plan(); } #[test] diff --git a/src/models/bucket.rs b/src/models/bucket.rs index 8140e6a..feffbb9 100644 --- a/src/models/bucket.rs +++ b/src/models/bucket.rs @@ -8,52 +8,122 @@ use serde::{Deserialize, Serialize}; pub struct Bucket { /// Bucket ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Bucket update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Bucket permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Whether file-level security is enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "fileSecurity")] + #[serde(default = "default_file_security")] pub file_security: bool, /// Bucket name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Bucket enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Maximum file size supported. #[serde(rename = "maximumFileSize")] + #[serde(default = "default_maximum_file_size")] pub maximum_file_size: i64, /// Allowed file extensions. #[serde(rename = "allowedFileExtensions")] + #[serde(default = "default_allowed_file_extensions")] pub allowed_file_extensions: Vec, /// Compression algorithm chosen for compression. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, /// Bucket is encrypted. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Virus scanning is enabled. #[serde(rename = "antivirus")] + #[serde(default = "default_antivirus")] pub antivirus: bool, /// Image transformations are enabled. #[serde(rename = "transformations")] + #[serde(default = "default_transformations")] pub transformations: bool, /// Total size of this bucket in bytes. #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_file_security() -> bool { + false +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_maximum_file_size() -> i64 { + 0 +} + +fn default_allowed_file_extensions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_compression() -> String { + "".to_string() +} + +fn default_encryption() -> bool { + true +} + +fn default_antivirus() -> bool { + true +} + +fn default_transformations() -> bool { + true +} + +fn default_total_size() -> i64 { + 0 +} + impl Bucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/bucket_list.rs b/src/models/bucket_list.rs index 0f76efc..a29bb00 100644 --- a/src/models/bucket_list.rs +++ b/src/models/bucket_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct BucketList { /// Total number of buckets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of buckets. #[serde(rename = "buckets")] + #[serde(default = "default_buckets")] pub buckets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_buckets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl BucketList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/collection.rs b/src/models/collection.rs index 715c303..fd9bc8a 100644 --- a/src/models/collection.rs +++ b/src/models/collection.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Collection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Collection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/collection_list.rs b/src/models/collection_list.rs index 97983c6..c9f7bfe 100644 --- a/src/models/collection_list.rs +++ b/src/models/collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_bigint.rs b/src/models/column_bigint.rs index 1228086..9dd23d7 100644 --- a/src/models/column_bigint.rs +++ b/src/models/column_bigint.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBigint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBigint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBigint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnBigint { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBigint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_boolean.rs b/src/models/column_boolean.rs index 65aa9af..d2f4fe9 100644 --- a/src/models/column_boolean.rs +++ b/src/models/column_boolean.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnBoolean { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnBoolean { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnBoolean { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnBoolean { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnBoolean { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_datetime.rs b/src/models/column_datetime.rs index a172665..13c23ca 100644 --- a/src/models/column_datetime.rs +++ b/src/models/column_datetime.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnDatetime { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnDatetime { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnDatetime { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ISO 8601 format. #[serde(rename = "format")] @@ -42,6 +48,30 @@ pub struct ColumnDatetime { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnDatetime { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_email.rs b/src/models/column_email.rs index f1c1037..5fc9bb6 100644 --- a/src/models/column_email.rs +++ b/src/models/column_email.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEmail { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEmail { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnEmail { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnEmail { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "email".to_string() +} + impl ColumnEmail { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_enum.rs b/src/models/column_enum.rs index d9b6b4f..bf66e79 100644 --- a/src/models/column_enum.rs +++ b/src/models/column_enum.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnEnum { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnEnum { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,15 +33,19 @@ pub struct ColumnEnum { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Array of elements in enumerated type. #[serde(rename = "elements")] + #[serde(default = "default_elements")] pub elements: Vec, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -46,6 +54,38 @@ pub struct ColumnEnum { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_elements() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_format() -> String { + "enum".to_string() +} + impl ColumnEnum { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_float.rs b/src/models/column_float.rs index 865bd38..55326bc 100644 --- a/src/models/column_float.rs +++ b/src/models/column_float.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnFloat { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnFloat { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnFloat { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnFloat { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnFloat { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_index.rs b/src/models/column_index.rs index 7e2a97b..ec406a7 100644 --- a/src/models/column_index.rs +++ b/src/models/column_index.rs @@ -8,32 +8,41 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndex { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Index columns length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +50,42 @@ pub struct ColumnIndex { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/column_index_list.rs b/src/models/column_index_list.rs index 2ea7645..748a2c5 100644 --- a/src/models/column_index_list.rs +++ b/src/models/column_index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnIndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_integer.rs b/src/models/column_integer.rs index 8a6cd9e..39fb5f6 100644 --- a/src/models/column_integer.rs +++ b/src/models/column_integer.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnInteger { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnInteger { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnInteger { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Minimum value to enforce for new documents. #[serde(rename = "min")] @@ -48,6 +54,30 @@ pub struct ColumnInteger { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnInteger { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_ip.rs b/src/models/column_ip.rs index a94cf00..9aa5287 100644 --- a/src/models/column_ip.rs +++ b/src/models/column_ip.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnIp { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnIp { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnIp { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnIp { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "ip".to_string() +} + impl ColumnIp { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_line.rs b/src/models/column_line.rs index 01d2239..6befae7 100644 --- a/src/models/column_line.rs +++ b/src/models/column_line.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLine { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLine { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLine { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnLine { pub default: Option>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLine { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_list.rs b/src/models/column_list.rs index aaa362b..55fc758 100644 --- a/src/models/column_list.rs +++ b/src/models/column_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ColumnList { /// Total number of columns in the given table. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ColumnList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/column_longtext.rs b/src/models/column_longtext.rs index 6d418d9..222e746 100644 --- a/src/models/column_longtext.rs +++ b/src/models/column_longtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnLongtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnLongtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnLongtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnLongtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnLongtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_mediumtext.rs b/src/models/column_mediumtext.rs index 90b3d33..f1c032b 100644 --- a/src/models/column_mediumtext.rs +++ b/src/models/column_mediumtext.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnMediumtext { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnMediumtext { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnMediumtext { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnMediumtext { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnMediumtext { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_point.rs b/src/models/column_point.rs index 6d402ea..4b08010 100644 --- a/src/models/column_point.rs +++ b/src/models/column_point.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPoint { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPoint { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPoint { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPoint { pub default: Option>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPoint { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_polygon.rs b/src/models/column_polygon.rs index d0afe7e..5ff50f0 100644 --- a/src/models/column_polygon.rs +++ b/src/models/column_polygon.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnPolygon { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnPolygon { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnPolygon { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -40,6 +46,30 @@ pub struct ColumnPolygon { pub default: Option>>>, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnPolygon { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_relationship.rs b/src/models/column_relationship.rs index 441476a..92304e7 100644 --- a/src/models/column_relationship.rs +++ b/src/models/column_relationship.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnRelationship { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnRelationship { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,30 +33,81 @@ pub struct ColumnRelationship { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The ID of the related table. #[serde(rename = "relatedTable")] pub related_table: String, /// The type of the relationship. #[serde(rename = "relationType")] + #[serde(default = "default_relation_type")] pub relation_type: String, /// Is the relationship two-way? #[serde(rename = "twoWay")] + #[serde(default = "default_two_way")] pub two_way: bool, /// The key of the two-way relationship. #[serde(rename = "twoWayKey")] + #[serde(default = "default_two_way_key")] pub two_way_key: String, /// How deleting the parent document will propagate to child documents. #[serde(rename = "onDelete")] + #[serde(default = "default_on_delete")] pub on_delete: String, /// Whether this is the parent or child side of the relationship #[serde(rename = "side")] + #[serde(default = "default_side")] pub side: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_relation_type() -> String { + "".to_string() +} + +fn default_two_way() -> bool { + false +} + +fn default_two_way_key() -> String { + "".to_string() +} + +fn default_on_delete() -> String { + "restrict".to_string() +} + +fn default_side() -> String { + "".to_string() +} + impl ColumnRelationship { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_string.rs b/src/models/column_string.rs index c7128c3..8d8e515 100644 --- a/src/models/column_string.rs +++ b/src/models/column_string.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnString { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnString { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnString { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnString { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnString { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_text.rs b/src/models/column_text.rs index 0ad76c5..e1b305c 100644 --- a/src/models/column_text.rs +++ b/src/models/column_text.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnText { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnText { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,9 +33,11 @@ pub struct ColumnText { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -44,6 +50,30 @@ pub struct ColumnText { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl ColumnText { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_url.rs b/src/models/column_url.rs index b509d2f..4fce4a3 100644 --- a/src/models/column_url.rs +++ b/src/models/column_url.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnUrl { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnUrl { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnUrl { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// String format. #[serde(rename = "format")] + #[serde(default = "default_format")] pub format: String, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -43,6 +50,34 @@ pub struct ColumnUrl { pub default: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_format() -> String { + "url".to_string() +} + impl ColumnUrl { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/column_varchar.rs b/src/models/column_varchar.rs index e163c87..53e8c58 100644 --- a/src/models/column_varchar.rs +++ b/src/models/column_varchar.rs @@ -8,9 +8,11 @@ use serde::{Deserialize, Serialize}; pub struct ColumnVarchar { /// Column Key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Column type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Column status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -19,9 +21,11 @@ pub struct ColumnVarchar { /// Error message. Displays error generated on failure of creating or deleting /// an column. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Is column required? #[serde(rename = "required")] + #[serde(default = "default_required")] pub required: bool, /// Is column an array? #[serde(rename = "array")] @@ -29,12 +33,15 @@ pub struct ColumnVarchar { pub array: Option, /// Column creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Column update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Column size. #[serde(rename = "size")] + #[serde(default = "default_size")] pub size: i64, /// Default value for column when not provided. Cannot be set when column is /// required. @@ -47,6 +54,34 @@ pub struct ColumnVarchar { pub encrypt: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_required() -> bool { + false +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_size() -> i64 { + 0 +} + impl ColumnVarchar { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/continent.rs b/src/models/continent.rs index c13199c..34286cd 100644 --- a/src/models/continent.rs +++ b/src/models/continent.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Continent { /// Continent name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Continent two letter code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Continent { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/continent_list.rs b/src/models/continent_list.rs index 2490dbd..677e579 100644 --- a/src/models/continent_list.rs +++ b/src/models/continent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ContinentList { /// Total number of continents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of continents. #[serde(rename = "continents")] + #[serde(default = "default_continents")] pub continents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_continents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ContinentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/country.rs b/src/models/country.rs index bf48f60..2c9db22 100644 --- a/src/models/country.rs +++ b/src/models/country.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Country { /// Country name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl Country { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/country_list.rs b/src/models/country_list.rs index bf4eeb1..b004cb8 100644 --- a/src/models/country_list.rs +++ b/src/models/country_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CountryList { /// Total number of countries that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of countries. #[serde(rename = "countries")] + #[serde(default = "default_countries")] pub countries: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_countries() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CountryList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/currency.rs b/src/models/currency.rs index 9d45fe6..c5d5091 100644 --- a/src/models/currency.rs +++ b/src/models/currency.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct Currency { /// Currency symbol. #[serde(rename = "symbol")] + #[serde(default = "default_symbol")] pub symbol: String, /// Currency name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Currency native symbol. #[serde(rename = "symbolNative")] + #[serde(default = "default_symbol_native")] pub symbol_native: String, /// Number of decimal digits. #[serde(rename = "decimalDigits")] + #[serde(default = "default_decimal_digits")] pub decimal_digits: i64, /// Currency digit rounding. #[serde(rename = "rounding")] + #[serde(default = "default_rounding")] pub rounding: f64, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Currency plural name #[serde(rename = "namePlural")] + #[serde(default = "default_name_plural")] pub name_plural: String, } +fn default_symbol() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_symbol_native() -> String { + "".to_string() +} + +fn default_decimal_digits() -> i64 { + 0 +} + +fn default_rounding() -> f64 { + 0.0 +} + +fn default_code() -> String { + "".to_string() +} + +fn default_name_plural() -> String { + "".to_string() +} + impl Currency { /// Get symbol pub fn symbol(&self) -> &String { diff --git a/src/models/currency_list.rs b/src/models/currency_list.rs index 86fa828..001a779 100644 --- a/src/models/currency_list.rs +++ b/src/models/currency_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct CurrencyList { /// Total number of currencies that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of currencies. #[serde(rename = "currencies")] + #[serde(default = "default_currencies")] pub currencies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_currencies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl CurrencyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database.rs b/src/models/database.rs index 5c0a45d..b582d01 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -8,23 +8,29 @@ use serde::{Deserialize, Serialize}; pub struct Database { /// Database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Database creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the /// database is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Database type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: crate::enums::DatabaseType, /// Dedicated database lifecycle status. Null when the database has no valid /// dedicated backing. @@ -53,8 +59,9 @@ pub struct Database { #[serde(rename = "error")] #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, - /// Container status of the dedicated backing: active or inactive. Null when - /// the database has no dedicated backing or the runtime has not reported one. + /// Container status of the dedicated backing: active, inactive, or failed (a + /// wake was declined because the backing namespace is gone). Null when the + /// database has no dedicated backing or the runtime has not reported one. #[serde(rename = "containerStatus")] #[serde(skip_serializing_if = "Option::is_none")] pub container_status: Option, @@ -74,6 +81,30 @@ pub struct Database { pub archives: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> crate::enums::DatabaseType { + serde_json::from_value(serde_json::json!("legacy")).unwrap() +} + impl Database { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_list.rs b/src/models/database_list.rs index 78fe039..919f60b 100644 --- a/src/models/database_list.rs +++ b/src/models/database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_migration.rs b/src/models/database_migration.rs index 0a05aa6..e2ca204 100644 --- a/src/models/database_migration.rs +++ b/src/models/database_migration.rs @@ -8,63 +8,148 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigration { /// Database migration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Migration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Migration update time in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns the migrating database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Logical database ID being migrated. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Dedicated compute specification provisioned for the migration target. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Migration phase. Possible values: pending, provisioned, capturing, /// backfilling, catching_up, verifying, ready_to_cutover, cutover, soaking, /// done, failed, rolled_back. #[serde(rename = "phase")] + #[serde(default = "default_phase")] pub phase: String, /// Number of times a migration step has failed and been recorded. #[serde(rename = "attempt")] + #[serde(default = "default_attempt")] pub attempt: i64, /// Reason the most recent migration step failed, empty while none has. #[serde(rename = "lastError")] + #[serde(default = "default_last_error")] pub last_error: String, /// Number of documents still pending replication to the target. #[serde(rename = "lagDocuments")] + #[serde(default = "default_lag_documents")] pub lag_documents: i64, /// Highest source changelog sequence applied to the target so far. #[serde(rename = "changelogWatermark")] + #[serde(default = "default_changelog_watermark")] pub changelog_watermark: i64, /// Time the migrated data was verified against the source in ISO 8601 format. #[serde(rename = "verifiedAt")] + #[serde(default = "default_verified_at")] pub verified_at: String, /// Time routing was flipped to the target in ISO 8601 format. #[serde(rename = "cutoverAt")] + #[serde(default = "default_cutover_at")] pub cutover_at: String, /// Time the post-cutover soak window ends in ISO 8601 format. #[serde(rename = "soakUntil")] + #[serde(default = "default_soak_until")] pub soak_until: String, /// Whether the migration cuts over automatically once ready. Set when the /// migration is created and never changed afterwards, so it always reports /// what was asked for. #[serde(rename = "autoCutover")] + #[serde(default = "default_auto_cutover")] pub auto_cutover: bool, /// Whether a cutover has been requested and not yet attempted. Set by the /// cutover endpoint and cleared when the attempt is made, so a cutover that /// fails a check parks the migration again rather than retrying on its own. #[serde(rename = "cutoverRequested")] + #[serde(default = "default_cutover_requested")] pub cutover_requested: bool, /// Whether the migration is paused. #[serde(rename = "paused")] + #[serde(default = "default_paused")] pub paused: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_phase() -> String { + "pending".to_string() +} + +fn default_attempt() -> i64 { + 0 +} + +fn default_last_error() -> String { + "".to_string() +} + +fn default_lag_documents() -> i64 { + 0 +} + +fn default_changelog_watermark() -> i64 { + 0 +} + +fn default_verified_at() -> String { + "".to_string() +} + +fn default_cutover_at() -> String { + "".to_string() +} + +fn default_soak_until() -> String { + "".to_string() +} + +fn default_auto_cutover() -> bool { + true +} + +fn default_cutover_requested() -> bool { + false +} + +fn default_paused() -> bool { + false +} + impl DatabaseMigration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/database_migration_list.rs b/src/models/database_migration_list.rs index ad8e45f..1029847 100644 --- a/src/models/database_migration_list.rs +++ b/src/models/database_migration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseMigrationList { /// Total number of migrations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of migrations. #[serde(rename = "migrations")] + #[serde(default = "default_migrations")] pub migrations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_migrations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseMigrationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/database_status.rs b/src/models/database_status.rs index d0b0403..0796051 100644 --- a/src/models/database_status.rs +++ b/src/models/database_status.rs @@ -9,25 +9,32 @@ pub struct DatabaseStatus { /// Overall health status: healthy, degraded, unhealthy, or unknown when /// nothing could be measured. #[serde(rename = "health")] + #[serde(default = "default_health")] pub health: String, /// Whether the database is ready to accept connections. #[serde(rename = "ready")] + #[serde(default = "default_ready")] pub ready: bool, /// Database engine: postgresql, mysql, or mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Database uptime in seconds. #[serde(rename = "uptime")] + #[serde(default = "default_uptime")] pub uptime: i64, - /// Connection statistics. + /// Connection statistics. Null when the database has not been probed. #[serde(rename = "connections")] - pub connections: crate::models::DatabaseStatusConnections, + #[serde(skip_serializing_if = "Option::is_none")] + pub connections: Option, /// Requested replication sync mode. Possible values: async, sync, quorum. /// Compare with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. @@ -36,13 +43,16 @@ pub struct DatabaseStatus { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -62,12 +72,58 @@ pub struct DatabaseStatus { /// appears, including one the backend has not brought up, which is reported as /// not healthy. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: Vec, /// Storage volume information. #[serde(rename = "volumes")] + #[serde(default = "default_volumes")] pub volumes: Vec, } +fn default_health() -> String { + "unknown".to_string() +} + +fn default_ready() -> bool { + false +} + +fn default_engine() -> String { + "postgresql".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_uptime() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_replicas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_volumes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DatabaseStatus { /// Get health pub fn health(&self) -> &String { @@ -94,9 +150,18 @@ impl DatabaseStatus { &self.uptime } + /// Set connections + pub fn set_connections( + mut self, + connections: crate::models::DatabaseStatusConnections, + ) -> Self { + self.connections = Some(connections); + self + } + /// Get connections - pub fn connections(&self) -> &crate::models::DatabaseStatusConnections { - &self.connections + pub fn connections(&self) -> Option<&crate::models::DatabaseStatusConnections> { + self.connections.as_ref() } /// Get sync_mode @@ -164,7 +229,6 @@ mod tests { let _ = _model.engine(); let _ = _model.version(); let _ = _model.uptime(); - let _ = _model.connections(); let _ = _model.sync_mode(); let _ = _model.sync_degraded(); let _ = _model.sync_acknowledgements(); diff --git a/src/models/database_status_connections.rs b/src/models/database_status_connections.rs index 0e7652d..8d7110a 100644 --- a/src/models/database_status_connections.rs +++ b/src/models/database_status_connections.rs @@ -8,14 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusConnections { /// Current number of active connections. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: i64, /// The engine's own max_connections. On a pooled database this is the backend /// limit the pooler multiplexes onto, not the ceiling a client pool may reach /// — that is networkMaxConnections on the database resource. #[serde(rename = "max")] + #[serde(default = "default_max")] pub max: i64, } +fn default_current() -> i64 { + 0 +} + +fn default_max() -> i64 { + 100 +} + impl DatabaseStatusConnections { /// Get current pub fn current(&self) -> &i64 { diff --git a/src/models/database_status_replica.rs b/src/models/database_status_replica.rs index f182cdb..ad15e30 100644 --- a/src/models/database_status_replica.rs +++ b/src/models/database_status_replica.rs @@ -9,15 +9,18 @@ pub struct DatabaseStatusReplica { /// Member index within the database. Read `role` for which member accepts /// writes: a failover moves the primary without renumbering the indexes. #[serde(rename = "index")] + #[serde(default = "default_index")] pub index: i64, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology, so no member can be named /// the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Whether the replica is healthy. #[serde(rename = "healthy")] + #[serde(default = "default_healthy")] pub healthy: bool, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -35,6 +38,18 @@ pub struct DatabaseStatusReplica { pub lag_seconds: Option, } +fn default_index() -> i64 { + 0 +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_healthy() -> bool { + false +} + impl DatabaseStatusReplica { /// Get index pub fn index(&self) -> &i64 { diff --git a/src/models/database_status_volume.rs b/src/models/database_status_volume.rs index 35ea096..0d21f7a 100644 --- a/src/models/database_status_volume.rs +++ b/src/models/database_status_volume.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct DatabaseStatusVolume { /// Mount path of the volume. #[serde(rename = "path")] + #[serde(default = "default_path")] pub path: String, /// Percentage of storage used. #[serde(rename = "usedPercent")] + #[serde(default = "default_used_percent")] pub used_percent: String, /// Available storage space. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: String, /// Whether the volume is mounted. #[serde(rename = "mounted")] + #[serde(default = "default_mounted")] pub mounted: bool, } +fn default_path() -> String { + "".to_string() +} + +fn default_used_percent() -> String { + "0%".to_string() +} + +fn default_available() -> String { + "0GB".to_string() +} + +fn default_mounted() -> bool { + false +} + impl DatabaseStatusVolume { /// Get path pub fn path(&self) -> &String { diff --git a/src/models/dedicated_database.rs b/src/models/dedicated_database.rs index 33e9d5c..07cf2c4 100644 --- a/src/models/dedicated_database.rs +++ b/src/models/dedicated_database.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabase { /// Dedicated database ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Database creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project ID that owns this database. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Database display name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Product API that owns this database: tablesdb, documentsdb, vectorsdb, /// mysql, postgresql, or mongodb. #[serde(rename = "api")] - pub api: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub api: Option, /// Database engine: postgresql, mysql, or mongodb. Null until the backing /// reports one. #[serde(rename = "engine")] - pub engine: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub engine: Option, /// Database engine version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Specification identifier. #[serde(rename = "specification")] + #[serde(default = "default_specification")] pub specification: String, /// Database backend provider. Possible values: edge. #[serde(rename = "backend")] + #[serde(default = "default_backend")] pub backend: String, /// Database hostname for connections. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, /// Database port for connections. Derived from the engine when the backing has /// not reported one yet. #[serde(rename = "connectionPort")] - pub connection_port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub connection_port: Option, /// Database username for connections. #[serde(rename = "connectionUser")] + #[serde(default = "default_connection_user")] pub connection_user: String, /// Database password for connections. #[serde(rename = "connectionPassword")] + #[serde(default = "default_connection_password")] pub connection_password: String, /// Committed generation of the primary connection credentials. Null until the /// rotation contract has been initialized. #[serde(rename = "credentialGeneration")] - pub credential_generation: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub credential_generation: Option, /// Full database connection string (URI format). #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, /// Whether SSL/TLS is required for client connections. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database status. Possible values: provisioning, ready, inactive, paused, /// failed, deleted, restoring, scaling. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, - /// Container status for lifecycle-managed database runtimes: active or - /// inactive. + /// Container status for lifecycle-managed database runtimes: active, inactive, + /// or failed (a wake was declined because the backing namespace is gone). #[serde(rename = "containerStatus")] + #[serde(default = "default_container_status")] pub container_status: String, /// Last activity timestamp in ISO 8601 format. #[serde(rename = "lastAccessedAt")] @@ -82,29 +101,34 @@ pub struct DedicatedDatabase { /// Idle-lifecycle state of the database. Possible values: active, warm, cold, /// hibernated. #[serde(rename = "lifecycleState")] + #[serde(default = "default_lifecycle_state")] pub lifecycle_state: String, /// Minutes of inactivity before container scales to zero. #[serde(rename = "idleTimeoutMinutes")] + #[serde(default = "default_idle_timeout_minutes")] pub idle_timeout_minutes: i64, /// CPU allocated in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Memory allocated in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Storage allocated in GB. #[serde(rename = "storage")] + #[serde(default = "default_storage")] pub storage: i64, /// Storage resize status. Possible values: idle (no resize in flight), /// resizing (the volume is growing towards storageTargetGb). #[serde(rename = "storageStatus")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_status: Option, + #[serde(default = "default_storage_status")] + pub storage_status: String, /// Size in GB the volume is growing towards while storageStatus is resizing. 0 /// when no resize is in flight. #[serde(rename = "storageTargetGb")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_target_gb: Option, + #[serde(default = "default_storage_target_gb")] + pub storage_target_gb: i64, /// Time the in-flight storage resize started, in ISO 8601 format. #[serde(rename = "storageResizeStartedAt")] #[serde(skip_serializing_if = "Option::is_none")] @@ -112,86 +136,290 @@ pub struct DedicatedDatabase { /// Storage class. Currently always 'ssd'; DigitalOcean exposes a single /// block-storage class. #[serde(rename = "storageClass")] + #[serde(default = "default_storage_class")] pub storage_class: String, /// Maximum storage allowed in GB. 0 means use system default. #[serde(rename = "storageMaxGb")] + #[serde(default = "default_storage_max_gb")] pub storage_max_gb: i64, /// Kubernetes node pool where the database is scheduled. #[serde(rename = "nodePool")] + #[serde(default = "default_node_pool")] pub node_pool: String, /// Number of high availability replicas. High availability is enabled when /// greater than 0. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Replication sync mode: async, sync, or quorum. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Maximum concurrent client connections. This is the limit a client pool may /// reach; the engine's own max_connections reported by the status endpoint is /// a smaller backend limit the pooler multiplexes onto and does not constrain /// a client pool. #[serde(rename = "networkMaxConnections")] + #[serde(default = "default_network_max_connections")] pub network_max_connections: i64, /// Connection idle timeout in seconds. #[serde(rename = "networkIdleTimeoutSeconds")] + #[serde(default = "default_network_idle_timeout_seconds")] pub network_idle_timeout_seconds: i64, /// IP addresses/CIDR ranges allowed to connect. #[serde(rename = "networkIPAllowlist")] + #[serde(default = "default_network_ip_allowlist")] pub network_ip_allowlist: Vec, /// Whether automatic backups are enabled. #[serde(rename = "backupEnabled")] + #[serde(default = "default_backup_enabled")] pub backup_enabled: bool, /// Whether point-in-time recovery is enabled. #[serde(rename = "pitr")] + #[serde(default = "default_pitr")] pub pitr: bool, /// Number of days to retain PITR data. #[serde(rename = "pitrRetentionDays")] + #[serde(default = "default_pitr_retention_days")] pub pitr_retention_days: i64, /// Whether automatic storage expansion is enabled. #[serde(rename = "storageAutoscaling")] + #[serde(default = "default_storage_autoscaling")] pub storage_autoscaling: bool, /// Storage usage percentage that triggers automatic expansion. #[serde(rename = "storageAutoscalingThresholdPercent")] + #[serde(default = "default_storage_autoscaling_threshold_percent")] pub storage_autoscaling_threshold_percent: i64, - /// Maximum storage size in GB for autoscaling. 0 means no limit. + /// Maximum storage size in GB for autoscaling. Defaults to 3 times the + /// specification's storage. 0 means no limit. #[serde(rename = "storageAutoscalingMaxGb")] + #[serde(default = "default_storage_autoscaling_max_gb")] pub storage_autoscaling_max_gb: i64, /// Day of the week for the maintenance window. Possible values: sun, mon, tue, /// wed, thu, fri, sat. #[serde(rename = "maintenanceWindowDay")] + #[serde(default = "default_maintenance_window_day")] pub maintenance_window_day: String, /// Hour in UTC (0-23) when the maintenance window starts. #[serde(rename = "maintenanceWindowHourUtc")] + #[serde(default = "default_maintenance_window_hour_utc")] pub maintenance_window_hour_utc: i64, /// Whether metrics collection is enabled. #[serde(rename = "metricsEnabled")] + #[serde(default = "default_metrics_enabled")] pub metrics_enabled: bool, /// Whether the SQL API sidecar is enabled for this database. #[serde(rename = "sqlApiEnabled")] + #[serde(default = "default_sql_api_enabled")] pub sql_api_enabled: bool, /// Statement types accepted by the SQL API. Defaults to read/write DML only; /// DDL/DCL types (CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE) are opt-in per /// database. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, /// DROP, TRUNCATE, GRANT, REVOKE. #[serde(rename = "sqlApiAllowedStatements")] + #[serde(default = "default_sql_api_allowed_statements")] pub sql_api_allowed_statements: Vec, /// Maximum rows returned per SQL API execution. Results larger than this are /// truncated. #[serde(rename = "sqlApiMaxRows")] + #[serde(default = "default_sql_api_max_rows")] pub sql_api_max_rows: i64, /// Maximum serialised SQL API result payload in bytes. Results larger than /// this are truncated. #[serde(rename = "sqlApiMaxBytes")] + #[serde(default = "default_sql_api_max_bytes")] pub sql_api_max_bytes: i64, /// Maximum server-side SQL API execution time in seconds before the query is /// cancelled. #[serde(rename = "sqlApiTimeoutSeconds")] + #[serde(default = "default_sql_api_timeout_seconds")] pub sql_api_timeout_seconds: i64, /// Error message if status is failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_specification() -> String { + "".to_string() +} + +fn default_backend() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + +fn default_connection_user() -> String { + "".to_string() +} + +fn default_connection_password() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_status() -> String { + "provisioning".to_string() +} + +fn default_container_status() -> String { + "".to_string() +} + +fn default_lifecycle_state() -> String { + "".to_string() +} + +fn default_idle_timeout_minutes() -> i64 { + 15 +} + +fn default_cpu() -> i64 { + 500 +} + +fn default_memory() -> i64 { + 512 +} + +fn default_storage() -> i64 { + 10 +} + +fn default_storage_status() -> String { + "idle".to_string() +} + +fn default_storage_target_gb() -> i64 { + 0 +} + +fn default_storage_class() -> String { + "ssd".to_string() +} + +fn default_storage_max_gb() -> i64 { + 0 +} + +fn default_node_pool() -> String { + "".to_string() +} + +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "".to_string() +} + +fn default_network_max_connections() -> i64 { + 100 +} + +fn default_network_idle_timeout_seconds() -> i64 { + 900 +} + +fn default_network_ip_allowlist() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_backup_enabled() -> bool { + true +} + +fn default_pitr() -> bool { + true +} + +fn default_pitr_retention_days() -> i64 { + 7 +} + +fn default_storage_autoscaling() -> bool { + true +} + +fn default_storage_autoscaling_threshold_percent() -> i64 { + 85 +} + +fn default_storage_autoscaling_max_gb() -> i64 { + 0 +} + +fn default_maintenance_window_day() -> String { + "sun".to_string() +} + +fn default_maintenance_window_hour_utc() -> i64 { + 3 +} + +fn default_metrics_enabled() -> bool { + false +} + +fn default_sql_api_enabled() -> bool { + true +} + +fn default_sql_api_allowed_statements() -> Vec { + serde_json::from_value(serde_json::json!(["SELECT", "INSERT", "UPDATE", "DELETE"])).unwrap() +} + +fn default_sql_api_max_rows() -> i64 { + 10000 +} + +fn default_sql_api_max_bytes() -> i64 { + 10485760 +} + +fn default_sql_api_timeout_seconds() -> i64 { + 30 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabase { /// Get id pub fn id(&self) -> &String { @@ -218,14 +446,26 @@ impl DedicatedDatabase { &self.name } + /// Set api + pub fn set_api(mut self, api: String) -> Self { + self.api = Some(api); + self + } + /// Get api - pub fn api(&self) -> &String { - &self.api + pub fn api(&self) -> Option<&String> { + self.api.as_ref() + } + + /// Set engine + pub fn set_engine(mut self, engine: String) -> Self { + self.engine = Some(engine); + self } /// Get engine - pub fn engine(&self) -> &String { - &self.engine + pub fn engine(&self) -> Option<&String> { + self.engine.as_ref() } /// Get version @@ -248,9 +488,15 @@ impl DedicatedDatabase { &self.hostname } + /// Set connection_port + pub fn set_connection_port(mut self, connection_port: i64) -> Self { + self.connection_port = Some(connection_port); + self + } + /// Get connection_port - pub fn connection_port(&self) -> &i64 { - &self.connection_port + pub fn connection_port(&self) -> Option<&i64> { + self.connection_port.as_ref() } /// Get connection_user @@ -263,9 +509,15 @@ impl DedicatedDatabase { &self.connection_password } + /// Set credential_generation + pub fn set_credential_generation(mut self, credential_generation: i64) -> Self { + self.credential_generation = Some(credential_generation); + self + } + /// Get credential_generation - pub fn credential_generation(&self) -> &i64 { - &self.credential_generation + pub fn credential_generation(&self) -> Option<&i64> { + self.credential_generation.as_ref() } /// Get connection_string @@ -335,26 +587,14 @@ impl DedicatedDatabase { &self.storage } - /// Set storage_status - pub fn set_storage_status(mut self, storage_status: String) -> Self { - self.storage_status = Some(storage_status); - self - } - /// Get storage_status - pub fn storage_status(&self) -> Option<&String> { - self.storage_status.as_ref() - } - - /// Set storage_target_gb - pub fn set_storage_target_gb(mut self, storage_target_gb: i64) -> Self { - self.storage_target_gb = Some(storage_target_gb); - self + pub fn storage_status(&self) -> &String { + &self.storage_status } /// Get storage_target_gb - pub fn storage_target_gb(&self) -> Option<&i64> { - self.storage_target_gb.as_ref() + pub fn storage_target_gb(&self) -> &i64 { + &self.storage_target_gb } /// Set storage_resize_started_at @@ -496,16 +736,12 @@ mod tests { let _ = _model.updated_at(); let _ = _model.project_id(); let _ = _model.name(); - let _ = _model.api(); - let _ = _model.engine(); let _ = _model.version(); let _ = _model.specification(); let _ = _model.backend(); let _ = _model.hostname(); - let _ = _model.connection_port(); let _ = _model.connection_user(); let _ = _model.connection_password(); - let _ = _model.credential_generation(); let _ = _model.connection_string(); let _ = _model.ssl(); let _ = _model.status(); @@ -515,6 +751,8 @@ mod tests { let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.storage(); + let _ = _model.storage_status(); + let _ = _model.storage_target_gb(); let _ = _model.storage_class(); let _ = _model.storage_max_gb(); let _ = _model.node_pool(); diff --git a/src/models/dedicated_database_backup.rs b/src/models/dedicated_database_backup.rs index 703d3d6..cef73b2 100644 --- a/src/models/dedicated_database_backup.rs +++ b/src/models/dedicated_database_backup.rs @@ -8,44 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackup { /// Backup ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Backup creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID this backup belongs to. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup policy ID when the backup was created by a schedule. #[serde(rename = "policyId")] + #[serde(default = "default_policy_id")] pub policy_id: String, /// Backup trigger. Possible values: manual, schedule. #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// Backup type. Possible values: full (complete database snapshot), /// incremental (changes since last backup), wal (write-ahead log continuous /// archival). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Backup type that was requested. Differs from `type` when the backend could /// not run the requested type and took a different one instead, in which case /// `fallbackReason` explains why. Empty for backups taken before the requested /// type was recorded. #[serde(rename = "requestedType")] + #[serde(default = "default_requested_type")] pub requested_type: String, /// Why the backend ran a different backup type than the one requested. Empty /// when the backup ran as requested. #[serde(rename = "fallbackReason")] + #[serde(default = "default_fallback_reason")] pub fallback_reason: String, /// Backup status. Possible values: pending (queued for processing), running /// (currently in progress), completed (successfully finished), failed /// (encountered an error), verified (integrity check passed). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Backup size in bytes. #[serde(rename = "sizeBytes")] + #[serde(default = "default_size_bytes")] pub size_bytes: i64, /// Backup start time in ISO 8601 format. #[serde(rename = "startedAt")] @@ -73,9 +84,58 @@ pub struct DedicatedDatabaseBackup { pub log_position: Option, /// Error message if backup failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_policy_id() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "manual".to_string() +} + +fn default_type() -> String { + "full".to_string() +} + +fn default_requested_type() -> String { + "".to_string() +} + +fn default_fallback_reason() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_size_bytes() -> i64 { + 0 +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseBackup { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_backup_list.rs b/src/models/dedicated_database_backup_list.rs index 4833b14..7f173ad 100644 --- a/src/models/dedicated_database_backup_list.rs +++ b/src/models/dedicated_database_backup_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBackupList { /// Total number of backups. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of backups. #[serde(rename = "backups")] + #[serde(default = "default_backups")] pub backups: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_backups() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBackupList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_backup_storage.rs b/src/models/dedicated_database_backup_storage.rs index 395e376..6756910 100644 --- a/src/models/dedicated_database_backup_storage.rs +++ b/src/models/dedicated_database_backup_storage.rs @@ -9,21 +9,46 @@ pub struct DedicatedDatabaseBackupStorage { /// Storage provider. Possible values: s3 (Amazon S3 or S3-compatible), gcs /// (Google Cloud Storage), azure (Azure Blob Storage). #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Storage bucket or container name. #[serde(rename = "bucket")] + #[serde(default = "default_bucket")] pub bucket: String, /// Storage region. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// Object key prefix for backups. #[serde(rename = "prefix")] + #[serde(default = "default_prefix")] pub prefix: String, /// Custom endpoint for S3-compatible storage. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_provider() -> String { + "".to_string() +} + +fn default_bucket() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_prefix() -> String { + "backups/".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl DedicatedDatabaseBackupStorage { /// Get provider pub fn provider(&self) -> &String { diff --git a/src/models/dedicated_database_branch.rs b/src/models/dedicated_database_branch.rs index db3bc19..6d283bf 100644 --- a/src/models/dedicated_database_branch.rs +++ b/src/models/dedicated_database_branch.rs @@ -8,43 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranch { /// Branch identifier. #[serde(rename = "branchId")] + #[serde(default = "default_branch_id")] pub branch_id: String, /// Branch name. #[serde(rename = "branchName")] + #[serde(default = "default_branch_name")] pub branch_name: String, /// Kubernetes namespace where the branch is deployed. #[serde(rename = "namespace")] + #[serde(default = "default_namespace")] pub namespace: String, /// Unix timestamp when the branch expires. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: i64, /// Branch hostname for direct connections. #[serde(rename = "host")] + #[serde(default = "default_host")] pub host: String, /// Branch port. Null until the backing reports one. #[serde(rename = "port")] - pub port: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub port: Option, /// Advertised catalog the client connects to. MySQL/MariaDB use default; /// Postgres uses the routing label. #[serde(rename = "database")] + #[serde(default = "default_database")] pub database: String, /// Database username. Shared with the parent database. #[serde(rename = "username")] + #[serde(default = "default_username")] pub username: String, /// Database password. Shared with the parent database. #[serde(rename = "password")] + #[serde(default = "default_password")] pub password: String, /// Whether SSL is required. #[serde(rename = "ssl")] + #[serde(default = "default_ssl")] pub ssl: bool, /// Database engine. Possible values: postgresql, mysql, mongodb. #[serde(rename = "engine")] + #[serde(default = "default_engine")] pub engine: String, /// Full connection string for the branch. #[serde(rename = "connectionString")] + #[serde(default = "default_connection_string")] pub connection_string: String, } +fn default_branch_id() -> String { + "".to_string() +} + +fn default_branch_name() -> String { + "".to_string() +} + +fn default_namespace() -> String { + "".to_string() +} + +fn default_expires_at() -> i64 { + 0 +} + +fn default_host() -> String { + "".to_string() +} + +fn default_database() -> String { + "".to_string() +} + +fn default_username() -> String { + "".to_string() +} + +fn default_password() -> String { + "".to_string() +} + +fn default_ssl() -> bool { + false +} + +fn default_engine() -> String { + "".to_string() +} + +fn default_connection_string() -> String { + "".to_string() +} + impl DedicatedDatabaseBranch { /// Get branch_id pub fn branch_id(&self) -> &String { @@ -71,9 +127,15 @@ impl DedicatedDatabaseBranch { &self.host } + /// Set port + pub fn set_port(mut self, port: i64) -> Self { + self.port = Some(port); + self + } + /// Get port - pub fn port(&self) -> &i64 { - &self.port + pub fn port(&self) -> Option<&i64> { + self.port.as_ref() } /// Get database @@ -119,7 +181,6 @@ mod tests { let _ = _model.namespace(); let _ = _model.expires_at(); let _ = _model.host(); - let _ = _model.port(); let _ = _model.database(); let _ = _model.username(); let _ = _model.password(); diff --git a/src/models/dedicated_database_branch_list.rs b/src/models/dedicated_database_branch_list.rs index 50da757..adb1575 100644 --- a/src/models/dedicated_database_branch_list.rs +++ b/src/models/dedicated_database_branch_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseBranchList { /// Total number of branches. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of branches. #[serde(rename = "branches")] + #[serde(default = "default_branches")] pub branches: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseBranchList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_execution.rs b/src/models/dedicated_database_execution.rs index cbd430a..5998d80 100644 --- a/src/models/dedicated_database_execution.rs +++ b/src/models/dedicated_database_execution.rs @@ -9,26 +9,56 @@ pub struct DedicatedDatabaseExecution { /// Result rows as a list of column-name => value maps. Empty for non-returning /// statements. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, /// Number of rows returned (for SELECT) or affected (for /// INSERT/UPDATE/DELETE). #[serde(rename = "rowCount")] + #[serde(default = "default_row_count")] pub row_count: i64, /// Column metadata in result-set order. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Server-side execution time in milliseconds. #[serde(rename = "durationMs")] + #[serde(default = "default_duration_ms")] pub duration_ms: i64, /// True when the configured row or byte cap was hit and the result was /// truncated. #[serde(rename = "truncated")] + #[serde(default = "default_truncated")] pub truncated: bool, /// Serialised payload size in bytes. #[serde(rename = "bytes")] + #[serde(default = "default_bytes")] pub bytes: i64, } +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_row_count() -> i64 { + 0 +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_duration_ms() -> i64 { + 0 +} + +fn default_truncated() -> bool { + false +} + +fn default_bytes() -> i64 { + 0 +} + impl DedicatedDatabaseExecution { /// Get rows pub fn rows(&self) -> &Vec { diff --git a/src/models/dedicated_database_execution_column.rs b/src/models/dedicated_database_execution_column.rs index 0ec270d..4ceffeb 100644 --- a/src/models/dedicated_database_execution_column.rs +++ b/src/models/dedicated_database_execution_column.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExecutionColumn { /// Column name as returned by the database. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Engine-specific column type (e.g. int4, text, timestamptz). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + impl DedicatedDatabaseExecutionColumn { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/dedicated_database_extensions.rs b/src/models/dedicated_database_extensions.rs index eefa389..a1a9d2f 100644 --- a/src/models/dedicated_database_extensions.rs +++ b/src/models/dedicated_database_extensions.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseExtensions { /// List of installed extensions. #[serde(rename = "installed")] + #[serde(default = "default_installed")] pub installed: Vec, /// List of available extensions that can be installed. #[serde(rename = "available")] + #[serde(default = "default_available")] pub available: Vec, /// Curated metadata (display name, description, category) for each available /// extension. #[serde(rename = "metadata")] + #[serde(default = "default_metadata")] pub metadata: Vec, } +fn default_installed() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_available() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_metadata() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseExtensions { /// Get installed pub fn installed(&self) -> &Vec { diff --git a/src/models/dedicated_database_list.rs b/src/models/dedicated_database_list.rs index 7c68b07..40a0892 100644 --- a/src/models/dedicated_database_list.rs +++ b/src/models/dedicated_database_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseList { /// Total number of databases that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of databases. #[serde(rename = "databases")] + #[serde(default = "default_databases")] pub databases: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_databases() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_member.rs b/src/models/dedicated_database_member.rs index df7f0d1..9ab4fee 100644 --- a/src/models/dedicated_database_member.rs +++ b/src/models/dedicated_database_member.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseMember { /// Member identifier. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Member role. Possible values: primary (accepts reads and writes), replica /// (read-only follower), unknown (placement not established; reported while a /// transition is moving or restarting the topology and this member has not /// been probed, so no member can be named the write target). #[serde(rename = "role")] + #[serde(default = "default_role")] pub role: String, /// Member pod status. Possible values: pending (configured but absent from the /// backend topology, so nothing is bringing it up), provisioning (pod missing @@ -21,6 +23,7 @@ pub struct DedicatedDatabaseMember { /// failed (Failed phase or CrashLoopBackOff container), or the lowercased pod /// phase reported by the cluster. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Whether the engine reports this member's replication stream as up. Null /// when no reading was taken: a primary has no stream to report, and a member @@ -41,6 +44,18 @@ pub struct DedicatedDatabaseMember { pub lag_seconds: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_role() -> String { + "unknown".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl DedicatedDatabaseMember { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation.rs b/src/models/dedicated_database_operation.rs index 4476b00..02c317c 100644 --- a/src/models/dedicated_database_operation.rs +++ b/src/models/dedicated_database_operation.rs @@ -8,24 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperation { /// Operation ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Operation creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID the operation ran against. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Operation type, such as provision, update, credentials-update, restore, /// pausing, resuming, failover, backup-create or cross-region-enable. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Operation status. Possible values: queued (accepted and waiting to resume), /// running (in progress), completed (finished successfully), failed (ended in /// an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of times this operation has been attempted. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, /// Time the operation was requested, in ISO 8601 format. #[serde(rename = "requestedAt")] @@ -42,12 +48,46 @@ pub struct DedicatedDatabaseOperation { /// Machine-readable failure code. `Interrupted` marks an attempt that ended /// before its outcome could be confirmed. #[serde(rename = "errorCode")] + #[serde(default = "default_error_code")] pub error_code: String, /// Failure message if the operation failed. #[serde(rename = "errorMessage")] + #[serde(default = "default_error_message")] pub error_message: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + +fn default_error_code() -> String { + "".to_string() +} + +fn default_error_message() -> String { + "".to_string() +} + impl DedicatedDatabaseOperation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/dedicated_database_operation_list.rs b/src/models/dedicated_database_operation_list.rs index 641721c..de4eb57 100644 --- a/src/models/dedicated_database_operation_list.rs +++ b/src/models/dedicated_database_operation_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseOperationList { /// Total number of operations. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of operations. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_operations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseOperationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_pitr_windows.rs b/src/models/dedicated_database_pitr_windows.rs index 52b2fe5..59240b4 100644 --- a/src/models/dedicated_database_pitr_windows.rs +++ b/src/models/dedicated_database_pitr_windows.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePITRWindows { /// Earliest available recovery point. #[serde(rename = "earliest")] + #[serde(default = "default_earliest")] pub earliest: String, /// Latest available recovery point. #[serde(rename = "latest")] + #[serde(default = "default_latest")] pub latest: String, } +fn default_earliest() -> String { + "".to_string() +} + +fn default_latest() -> String { + "".to_string() +} + impl DedicatedDatabasePITRWindows { /// Get earliest pub fn earliest(&self) -> &String { diff --git a/src/models/dedicated_database_pooler.rs b/src/models/dedicated_database_pooler.rs index d1fa674..2d23de5 100644 --- a/src/models/dedicated_database_pooler.rs +++ b/src/models/dedicated_database_pooler.rs @@ -8,49 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabasePooler { /// Whether connection pooling is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Connection pool mode. Possible values: transaction (releases connections /// back to pool after each transaction), session (holds connections for the /// entire client session). #[serde(rename = "mode")] + #[serde(default = "default_mode")] pub mode: String, /// Client-connection ceiling the pooler accepts. Enforced on MySQL and /// MariaDB; on PostgreSQL the pooler has no client cap, so this reports the /// database's advertised networkMaxConnections and cannot be set here. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Default pool size per user. #[serde(rename = "defaultPoolSize")] + #[serde(default = "default_default_pool_size")] pub default_pool_size: i64, /// Pooler listening port. #[serde(rename = "port")] + #[serde(default = "default_port")] pub port: i64, /// Whether SELECTs are routed to HA replicas while writes and locked reads /// stay on the primary. Active only when HA is enabled. #[serde(rename = "readWriteSplitting")] + #[serde(default = "default_read_write_splitting")] pub read_write_splitting: bool, /// Effective CPU request applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (5% of DB CPU, floor 100m) /// unless overridden. #[serde(rename = "poolerCpuRequest")] + #[serde(default = "default_pooler_cpu_request")] pub pooler_cpu_request: String, /// Effective CPU limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (10% of DB CPU, floor 200m) /// unless overridden. #[serde(rename = "poolerCpuLimit")] + #[serde(default = "default_pooler_cpu_limit")] pub pooler_cpu_limit: String, /// Effective memory request applied to the pooler sidecar container /// (Kubernetes quantity). Returns the proportional default (7.5% of DB memory, /// floor 64Mi) unless overridden. #[serde(rename = "poolerMemoryRequest")] + #[serde(default = "default_pooler_memory_request")] pub pooler_memory_request: String, /// Effective memory limit applied to the pooler sidecar container (Kubernetes /// quantity). Returns the proportional default (15% of DB memory, floor 128Mi) /// unless overridden. #[serde(rename = "poolerMemoryLimit")] + #[serde(default = "default_pooler_memory_limit")] pub pooler_memory_limit: String, } +fn default_enabled() -> bool { + false +} + +fn default_mode() -> String { + "transaction".to_string() +} + +fn default_max_connections() -> i64 { + 100 +} + +fn default_default_pool_size() -> i64 { + 20 +} + +fn default_port() -> i64 { + 6432 +} + +fn default_read_write_splitting() -> bool { + false +} + +fn default_pooler_cpu_request() -> String { + "".to_string() +} + +fn default_pooler_cpu_limit() -> String { + "".to_string() +} + +fn default_pooler_memory_request() -> String { + "".to_string() +} + +fn default_pooler_memory_limit() -> String { + "".to_string() +} + impl DedicatedDatabasePooler { /// Get enabled pub fn enabled(&self) -> &bool { diff --git a/src/models/dedicated_database_replicas.rs b/src/models/dedicated_database_replicas.rs index 24bd468..701d8cc 100644 --- a/src/models/dedicated_database_replicas.rs +++ b/src/models/dedicated_database_replicas.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseReplicas { /// Number of configured replicas. Zero means high availability is disabled. #[serde(rename = "replicas")] + #[serde(default = "default_replicas")] pub replicas: i64, /// Requested replication sync mode. Possible values: async (asynchronous, /// fastest), sync (synchronous, strong consistency), quorum (quorum-based, /// majority of replicas must confirm). This is what was asked for; compare it /// with effectiveSyncMode for what the primary is enforcing. #[serde(rename = "syncMode")] + #[serde(default = "default_sync_mode")] pub sync_mode: String, /// Replication sync mode the primary is actually enforcing. Null when high /// availability is disabled or the state could not be read. A value below the @@ -24,13 +26,16 @@ pub struct DedicatedDatabaseReplicas { pub effective_sync_mode: Option, /// Whether the enforced replication is weaker than the requested syncMode. #[serde(rename = "syncDegraded")] + #[serde(default = "default_sync_degraded")] pub sync_degraded: bool, /// Number of standby acknowledgements the primary waits for before a write is /// committed. Zero means writes are acknowledged locally. #[serde(rename = "syncAcknowledgements")] + #[serde(default = "default_sync_acknowledgements")] pub sync_acknowledgements: i64, /// Number of standbys registered with the primary for synchronous replication. #[serde(rename = "syncStandbyCount")] + #[serde(default = "default_sync_standby_count")] pub sync_standby_count: i64, /// Whether the other sync fields are an engine reading rather than a recorded /// estimate. True when the primary answered what it is enforcing, including @@ -48,9 +53,34 @@ pub struct DedicatedDatabaseReplicas { pub sync_state_confirmed: Option, /// Per-pod statuses for the primary and every replica. #[serde(rename = "members")] + #[serde(default = "default_members")] pub members: Vec, } +fn default_replicas() -> i64 { + 0 +} + +fn default_sync_mode() -> String { + "async".to_string() +} + +fn default_sync_degraded() -> bool { + false +} + +fn default_sync_acknowledgements() -> i64 { + 0 +} + +fn default_sync_standby_count() -> i64 { + 0 +} + +fn default_members() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseReplicas { /// Get replicas pub fn replicas(&self) -> &i64 { diff --git a/src/models/dedicated_database_restoration.rs b/src/models/dedicated_database_restoration.rs index e52fefd..0af230f 100644 --- a/src/models/dedicated_database_restoration.rs +++ b/src/models/dedicated_database_restoration.rs @@ -8,45 +8,97 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestoration { /// Restoration ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Restoration creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Database ID being restored into. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Source database ID when restoring a backup into another database. #[serde(rename = "sourceDatabaseId")] - pub source_database_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub source_database_id: Option, /// Project ID. #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] pub project_id: String, /// Backup ID used for restoration (null for PITR). #[serde(rename = "backupId")] - pub backup_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub backup_id: Option, /// Restoration type. Possible values: backup (restore from a specific backup /// snapshot), pitr (point-in-time recovery to a specific timestamp). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, + /// Where the backup was restored. Possible values: in_place (replayed over the + /// database that took the backup), clone (recovered onto a second workload + /// beside the database, which keeps serving until the clone is promoted onto + /// its endpoint), copy (recovered onto a separate database with its own + /// endpoint). + #[serde(rename = "restoreMode")] + #[serde(default = "default_restore_mode")] + pub restore_mode: String, /// Restoration status. Possible values: pending (queued for processing), /// running (currently in progress), completed (successfully finished), failed /// (encountered an error). #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Target time for PITR restoration in ISO 8601 format. #[serde(rename = "targetTime")] - pub target_time: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub target_time: Option, /// Restoration start time in ISO 8601 format. #[serde(rename = "startedAt")] - pub started_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, /// Restoration completion time in ISO 8601 format. #[serde(rename = "completedAt")] - pub completed_at: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub completed_at: Option, /// Error message if restoration failed. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "backup".to_string() +} + +fn default_restore_mode() -> String { + "in_place".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_error() -> String { + "".to_string() +} + impl DedicatedDatabaseRestoration { /// Get id pub fn id(&self) -> &String { @@ -63,9 +115,15 @@ impl DedicatedDatabaseRestoration { &self.database_id } + /// Set source_database_id + pub fn set_source_database_id(mut self, source_database_id: String) -> Self { + self.source_database_id = Some(source_database_id); + self + } + /// Get source_database_id - pub fn source_database_id(&self) -> &String { - &self.source_database_id + pub fn source_database_id(&self) -> Option<&String> { + self.source_database_id.as_ref() } /// Get project_id @@ -73,9 +131,15 @@ impl DedicatedDatabaseRestoration { &self.project_id } + /// Set backup_id + pub fn set_backup_id(mut self, backup_id: String) -> Self { + self.backup_id = Some(backup_id); + self + } + /// Get backup_id - pub fn backup_id(&self) -> &String { - &self.backup_id + pub fn backup_id(&self) -> Option<&String> { + self.backup_id.as_ref() } /// Get r#type @@ -83,24 +147,47 @@ impl DedicatedDatabaseRestoration { &self.r#type } + /// Get restore_mode + pub fn restore_mode(&self) -> &String { + &self.restore_mode + } + /// Get status pub fn status(&self) -> &String { &self.status } + /// Set target_time + pub fn set_target_time(mut self, target_time: String) -> Self { + self.target_time = Some(target_time); + self + } + /// Get target_time - pub fn target_time(&self) -> &String { - &self.target_time + pub fn target_time(&self) -> Option<&String> { + self.target_time.as_ref() + } + + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self } /// Get started_at - pub fn started_at(&self) -> &String { - &self.started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() + } + + /// Set completed_at + pub fn set_completed_at(mut self, completed_at: String) -> Self { + self.completed_at = Some(completed_at); + self } /// Get completed_at - pub fn completed_at(&self) -> &String { - &self.completed_at + pub fn completed_at(&self) -> Option<&String> { + self.completed_at.as_ref() } /// Get error @@ -119,14 +206,10 @@ mod tests { let _ = _model.id(); let _ = _model.created_at(); let _ = _model.database_id(); - let _ = _model.source_database_id(); let _ = _model.project_id(); - let _ = _model.backup_id(); let _ = _model.r#type(); + let _ = _model.restore_mode(); let _ = _model.status(); - let _ = _model.target_time(); - let _ = _model.started_at(); - let _ = _model.completed_at(); let _ = _model.error(); } diff --git a/src/models/dedicated_database_restoration_list.rs b/src/models/dedicated_database_restoration_list.rs index 3d24d00..170ff62 100644 --- a/src/models/dedicated_database_restoration_list.rs +++ b/src/models/dedicated_database_restoration_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseRestorationList { /// Total number of restorations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of restorations. #[serde(rename = "restorations")] + #[serde(default = "default_restorations")] pub restorations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_restorations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DedicatedDatabaseRestorationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dedicated_database_specification.rs b/src/models/dedicated_database_specification.rs index 7dab746..f2bc9ee 100644 --- a/src/models/dedicated_database_specification.rs +++ b/src/models/dedicated_database_specification.rs @@ -8,49 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecification { /// Specification slug. Use this value when creating a dedicated database. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, /// Human readable specification name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Monthly price of the specification in USD. #[serde(rename = "price")] + #[serde(default = "default_price")] pub price: f64, /// Price per GB of storage above the included amount, per month, in USD. #[serde(rename = "storageOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub storage_overage_rate: Option, + #[serde(default = "default_storage_overage_rate")] + pub storage_overage_rate: f64, /// Price per GB of bandwidth above the included amount, per month, in USD. #[serde(rename = "bandwidthOverageRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub bandwidth_overage_rate: Option, + #[serde(default = "default_bandwidth_overage_rate")] + pub bandwidth_overage_rate: f64, /// High availability replica price as a fraction of the specification price. #[serde(rename = "replicaRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub replica_rate: Option, + #[serde(default = "default_replica_rate")] + pub replica_rate: f64, /// Point-in-time recovery price as a fraction of the specification price. #[serde(rename = "pitrRate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pitr_rate: Option, + #[serde(default = "default_pitr_rate")] + pub pitr_rate: f64, /// Allocated CPU in millicores. #[serde(rename = "cpu")] + #[serde(default = "default_cpu")] pub cpu: i64, /// Allocated memory in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Maximum number of concurrent connections. #[serde(rename = "maxConnections")] + #[serde(default = "default_max_connections")] pub max_connections: i64, /// Included storage in GB before overage charges apply. #[serde(rename = "includedStorage")] + #[serde(default = "default_included_storage")] pub included_storage: i64, /// Included bandwidth in GB before overage charges apply. #[serde(rename = "includedBandwidth")] + #[serde(default = "default_included_bandwidth")] pub included_bandwidth: i64, /// Whether the specification is available on the current plan. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_slug() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_price() -> f64 { + 0.0 +} + +fn default_storage_overage_rate() -> f64 { + 0.0 +} + +fn default_bandwidth_overage_rate() -> f64 { + 0.0 +} + +fn default_replica_rate() -> f64 { + 0.0 +} + +fn default_pitr_rate() -> f64 { + 0.0 +} + +fn default_cpu() -> i64 { + 0 +} + +fn default_memory() -> i64 { + 0 +} + +fn default_max_connections() -> i64 { + 0 +} + +fn default_included_storage() -> i64 { + 0 +} + +fn default_included_bandwidth() -> i64 { + 0 +} + +fn default_enabled() -> bool { + false +} + impl DedicatedDatabaseSpecification { /// Get slug pub fn slug(&self) -> &String { @@ -67,48 +128,24 @@ impl DedicatedDatabaseSpecification { &self.price } - /// Set storage_overage_rate - pub fn set_storage_overage_rate(mut self, storage_overage_rate: f64) -> Self { - self.storage_overage_rate = Some(storage_overage_rate); - self - } - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> Option<&f64> { - self.storage_overage_rate.as_ref() - } - - /// Set bandwidth_overage_rate - pub fn set_bandwidth_overage_rate(mut self, bandwidth_overage_rate: f64) -> Self { - self.bandwidth_overage_rate = Some(bandwidth_overage_rate); - self + pub fn storage_overage_rate(&self) -> &f64 { + &self.storage_overage_rate } /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> Option<&f64> { - self.bandwidth_overage_rate.as_ref() - } - - /// Set replica_rate - pub fn set_replica_rate(mut self, replica_rate: f64) -> Self { - self.replica_rate = Some(replica_rate); - self + pub fn bandwidth_overage_rate(&self) -> &f64 { + &self.bandwidth_overage_rate } /// Get replica_rate - pub fn replica_rate(&self) -> Option<&f64> { - self.replica_rate.as_ref() - } - - /// Set pitr_rate - pub fn set_pitr_rate(mut self, pitr_rate: f64) -> Self { - self.pitr_rate = Some(pitr_rate); - self + pub fn replica_rate(&self) -> &f64 { + &self.replica_rate } /// Get pitr_rate - pub fn pitr_rate(&self) -> Option<&f64> { - self.pitr_rate.as_ref() + pub fn pitr_rate(&self) -> &f64 { + &self.pitr_rate } /// Get cpu @@ -152,6 +189,10 @@ mod tests { let _ = _model.slug(); let _ = _model.name(); let _ = _model.price(); + let _ = _model.storage_overage_rate(); + let _ = _model.bandwidth_overage_rate(); + let _ = _model.replica_rate(); + let _ = _model.pitr_rate(); let _ = _model.cpu(); let _ = _model.memory(); let _ = _model.max_connections(); diff --git a/src/models/dedicated_database_specification_list.rs b/src/models/dedicated_database_specification_list.rs index 2be3453..e86f829 100644 --- a/src/models/dedicated_database_specification_list.rs +++ b/src/models/dedicated_database_specification_list.rs @@ -8,13 +8,20 @@ use serde::{Deserialize, Serialize}; pub struct DedicatedDatabaseSpecificationList { /// List of dedicated database specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, /// Total number of specifications. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, - /// Overage and add-on pricing shared across all specifications. - #[serde(rename = "pricing")] - pub pricing: crate::models::DedicatedDatabaseSpecificationPricing, +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_total() -> i64 { + 0 } impl DedicatedDatabaseSpecificationList { @@ -27,11 +34,6 @@ impl DedicatedDatabaseSpecificationList { pub fn total(&self) -> &i64 { &self.total } - - /// Get pricing - pub fn pricing(&self) -> &crate::models::DedicatedDatabaseSpecificationPricing { - &self.pricing - } } #[cfg(test)] @@ -43,7 +45,6 @@ mod tests { let _model = ::default(); let _ = _model.specifications(); let _ = _model.total(); - let _ = _model.pricing(); } #[test] diff --git a/src/models/dedicated_database_specification_pricing.rs b/src/models/dedicated_database_specification_pricing.rs deleted file mode 100644 index 0842526..0000000 --- a/src/models/dedicated_database_specification_pricing.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! DedicatedDatabaseSpecificationPricing model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// SpecificationPricing -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DedicatedDatabaseSpecificationPricing { - /// Price per GB of storage above the included amount, per month, in USD. - #[serde(rename = "storageOverageRate")] - pub storage_overage_rate: f64, - /// Price per GB of bandwidth above the included amount, per month, in USD. - #[serde(rename = "bandwidthOverageRate")] - pub bandwidth_overage_rate: f64, - /// High availability replica price as a fraction of the specification cost. - #[serde(rename = "replicaRate")] - pub replica_rate: f64, - /// Point-in-time recovery price as a fraction of the specification cost. - #[serde(rename = "pitrRate")] - pub pitr_rate: f64, -} - -impl DedicatedDatabaseSpecificationPricing { - /// Get storage_overage_rate - pub fn storage_overage_rate(&self) -> &f64 { - &self.storage_overage_rate - } - - /// Get bandwidth_overage_rate - pub fn bandwidth_overage_rate(&self) -> &f64 { - &self.bandwidth_overage_rate - } - - /// Get replica_rate - pub fn replica_rate(&self) -> &f64 { - &self.replica_rate - } - - /// Get pitr_rate - pub fn pitr_rate(&self) -> &f64 { - &self.pitr_rate - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dedicated_database_specification_pricing_creation() { - let _model = ::default(); - let _ = _model.storage_overage_rate(); - let _ = _model.bandwidth_overage_rate(); - let _ = _model.replica_rate(); - let _ = _model.pitr_rate(); - } - - #[test] - fn test_dedicated_database_specification_pricing_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = - serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/deployment.rs b/src/models/deployment.rs index 2da7e6f..78539b5 100644 --- a/src/models/deployment.rs +++ b/src/models/deployment.rs @@ -8,45 +8,59 @@ use serde::{Deserialize, Serialize}; pub struct Deployment { /// Deployment ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Deployment creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Deployment update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Type of deployment. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// The entrypoint file to use to execute the deployment code. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The code size in bytes. #[serde(rename = "sourceSize")] + #[serde(default = "default_source_size")] pub source_size: i64, /// The build output size in bytes. #[serde(rename = "buildSize")] + #[serde(default = "default_build_size")] pub build_size: i64, /// The total size in bytes (source and build output). #[serde(rename = "totalSize")] + #[serde(default = "default_total_size")] pub total_size: i64, /// The current build ID. #[serde(rename = "buildId")] + #[serde(default = "default_build_id")] pub build_id: String, /// Whether the deployment should be automatically activated. #[serde(rename = "activate")] + #[serde(default = "default_activate")] pub activate: bool, /// Screenshot with light theme preference file ID. #[serde(rename = "screenshotLight")] + #[serde(default = "default_screenshot_light")] pub screenshot_light: String, /// Screenshot with dark theme preference file ID. #[serde(rename = "screenshotDark")] + #[serde(default = "default_screenshot_dark")] pub screenshot_dark: String, /// The deployment status. Possible values are "waiting", "processing", /// "building", "ready", "canceled" and "failed". @@ -54,42 +68,158 @@ pub struct Deployment { pub status: crate::enums::DeploymentStatus, /// The build logs. #[serde(rename = "buildLogs")] + #[serde(default = "default_build_logs")] pub build_logs: String, /// The current build time in seconds. #[serde(rename = "buildDuration")] + #[serde(default = "default_build_duration")] pub build_duration: i64, /// The name of the vcs provider repository #[serde(rename = "providerRepositoryName")] + #[serde(default = "default_provider_repository_name")] pub provider_repository_name: String, /// The name of the vcs provider repository owner #[serde(rename = "providerRepositoryOwner")] + #[serde(default = "default_provider_repository_owner")] pub provider_repository_owner: String, /// The url of the vcs provider repository #[serde(rename = "providerRepositoryUrl")] + #[serde(default = "default_provider_repository_url")] pub provider_repository_url: String, /// The commit hash of the vcs commit #[serde(rename = "providerCommitHash")] + #[serde(default = "default_provider_commit_hash")] pub provider_commit_hash: String, /// The url of vcs commit author #[serde(rename = "providerCommitAuthorUrl")] + #[serde(default = "default_provider_commit_author_url")] pub provider_commit_author_url: String, /// The name of vcs commit author #[serde(rename = "providerCommitAuthor")] + #[serde(default = "default_provider_commit_author")] pub provider_commit_author: String, /// The commit message #[serde(rename = "providerCommitMessage")] + #[serde(default = "default_provider_commit_message")] pub provider_commit_message: String, /// The url of the vcs commit #[serde(rename = "providerCommitUrl")] + #[serde(default = "default_provider_commit_url")] pub provider_commit_url: String, /// The branch of the vcs repository #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// The branch of the vcs repository #[serde(rename = "providerBranchUrl")] + #[serde(default = "default_provider_branch_url")] pub provider_branch_url: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_source_size() -> i64 { + 0 +} + +fn default_build_size() -> i64 { + 0 +} + +fn default_total_size() -> i64 { + 0 +} + +fn default_build_id() -> String { + "".to_string() +} + +fn default_activate() -> bool { + false +} + +fn default_screenshot_light() -> String { + "".to_string() +} + +fn default_screenshot_dark() -> String { + "".to_string() +} + +fn default_build_logs() -> String { + "".to_string() +} + +fn default_build_duration() -> i64 { + 0 +} + +fn default_provider_repository_name() -> String { + "".to_string() +} + +fn default_provider_repository_owner() -> String { + "".to_string() +} + +fn default_provider_repository_url() -> String { + "".to_string() +} + +fn default_provider_commit_hash() -> String { + "".to_string() +} + +fn default_provider_commit_author_url() -> String { + "".to_string() +} + +fn default_provider_commit_author() -> String { + "".to_string() +} + +fn default_provider_commit_message() -> String { + "".to_string() +} + +fn default_provider_commit_url() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_branch_url() -> String { + "".to_string() +} + impl Deployment { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/deployment_list.rs b/src/models/deployment_list.rs index 5ee6ea7..f58b0b2 100644 --- a/src/models/deployment_list.rs +++ b/src/models/deployment_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DeploymentList { /// Total number of deployments that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of deployments. #[serde(rename = "deployments")] + #[serde(default = "default_deployments")] pub deployments: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_deployments() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DeploymentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/dev_key.rs b/src/models/dev_key.rs deleted file mode 100644 index 7b5ba1f..0000000 --- a/src/models/dev_key.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! DevKey model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// DevKey -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct DevKey { - /// Key ID. - #[serde(rename = "$id")] - pub id: String, - /// Key creation date in ISO 8601 format. - #[serde(rename = "$createdAt")] - pub created_at: String, - /// Key update date in ISO 8601 format. - #[serde(rename = "$updatedAt")] - pub updated_at: String, - /// Key name. - #[serde(rename = "name")] - pub name: String, - /// Key expiration date in ISO 8601 format. - #[serde(rename = "expire")] - pub expire: String, - /// Secret key. - #[serde(rename = "secret")] - pub secret: String, - /// Most recent access date in ISO 8601 format. This attribute is only updated - /// again after 24 hours. - #[serde(rename = "accessedAt")] - pub accessed_at: String, - /// List of SDK user agents that used this key. - #[serde(rename = "sdks")] - pub sdks: Vec, -} - -impl DevKey { - /// Get id - pub fn id(&self) -> &String { - &self.id - } - - /// Get created_at - pub fn created_at(&self) -> &String { - &self.created_at - } - - /// Get updated_at - pub fn updated_at(&self) -> &String { - &self.updated_at - } - - /// Get name - pub fn name(&self) -> &String { - &self.name - } - - /// Get expire - pub fn expire(&self) -> &String { - &self.expire - } - - /// Get secret - pub fn secret(&self) -> &String { - &self.secret - } - - /// Get accessed_at - pub fn accessed_at(&self) -> &String { - &self.accessed_at - } - - /// Get sdks - pub fn sdks(&self) -> &Vec { - &self.sdks - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_dev_key_creation() { - let _model = ::default(); - let _ = _model.id(); - let _ = _model.created_at(); - let _ = _model.updated_at(); - let _ = _model.name(); - let _ = _model.expire(); - let _ = _model.secret(); - let _ = _model.accessed_at(); - let _ = _model.sdks(); - } - - #[test] - fn test_dev_key_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/document.rs b/src/models/document.rs index 67c4a9c..0976976 100644 --- a/src/models/document.rs +++ b/src/models/document.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Document { /// Document ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Document sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Collection ID. #[serde(rename = "$collectionId")] + #[serde(default = "default_collection_id")] pub collection_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Document creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Document update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Document permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_collection_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Document { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/document_list.rs b/src/models/document_list.rs index bf9ba60..55f3143 100644 --- a/src/models/document_list.rs +++ b/src/models/document_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct DocumentList { /// Total number of documents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of documents. #[serde(rename = "documents")] + #[serde(default = "default_documents")] pub documents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_documents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl DocumentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/email_template.rs b/src/models/email_template.rs index 3236650..4ff064a 100644 --- a/src/models/email_template.rs +++ b/src/models/email_template.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplate { /// Template type #[serde(rename = "templateId")] + #[serde(default = "default_template_id")] pub template_id: String, /// Template locale #[serde(rename = "locale")] + #[serde(default = "default_locale")] pub locale: String, /// Template message #[serde(rename = "message")] + #[serde(default = "default_message")] pub message: String, /// Name of the sender #[serde(rename = "senderName")] + #[serde(default = "default_sender_name")] pub sender_name: String, /// Email of the sender #[serde(rename = "senderEmail")] + #[serde(default = "default_sender_email")] pub sender_email: String, /// Reply to email address #[serde(rename = "replyToEmail")] + #[serde(default = "default_reply_to_email")] pub reply_to_email: String, /// Reply to name #[serde(rename = "replyToName")] + #[serde(default = "default_reply_to_name")] pub reply_to_name: String, /// Email subject #[serde(rename = "subject")] + #[serde(default = "default_subject")] pub subject: String, } +fn default_template_id() -> String { + "".to_string() +} + +fn default_locale() -> String { + "".to_string() +} + +fn default_message() -> String { + "".to_string() +} + +fn default_sender_name() -> String { + "".to_string() +} + +fn default_sender_email() -> String { + "".to_string() +} + +fn default_reply_to_email() -> String { + "".to_string() +} + +fn default_reply_to_name() -> String { + "".to_string() +} + +fn default_subject() -> String { + "".to_string() +} + impl EmailTemplate { /// Get template_id pub fn template_id(&self) -> &String { diff --git a/src/models/email_template_list.rs b/src/models/email_template_list.rs index 02dbf9a..6d93da2 100644 --- a/src/models/email_template_list.rs +++ b/src/models/email_template_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmailTemplateList { /// Total number of templates that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of templates. #[serde(rename = "templates")] + #[serde(default = "default_templates")] pub templates: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_templates() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmailTemplateList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/embedding.rs b/src/models/embedding.rs index 1e26677..041e14d 100644 --- a/src/models/embedding.rs +++ b/src/models/embedding.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Embedding { /// Embedding model used to generate embeddings. #[serde(rename = "model")] + #[serde(default = "default_model")] pub model: String, /// Number of dimensions for each embedding vector. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, /// Embedding vector values. If an error occurs, this will be an empty array. #[serde(rename = "embedding")] + #[serde(default = "default_embedding")] pub embedding: Vec, /// Error message if embedding generation fails. Empty string if no error. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, } +fn default_model() -> String { + "".to_string() +} + +fn default_dimension() -> i64 { + 0 +} + +fn default_embedding() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_error() -> String { + "".to_string() +} + impl Embedding { /// Get model pub fn model(&self) -> &String { diff --git a/src/models/embedding_list.rs b/src/models/embedding_list.rs index 65f3074..25c9cbf 100644 --- a/src/models/embedding_list.rs +++ b/src/models/embedding_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct EmbeddingList { /// Total number of embeddings that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of embeddings. #[serde(rename = "embeddings")] + #[serde(default = "default_embeddings")] pub embeddings: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_embeddings() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EmbeddingList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/ephemeral_key.rs b/src/models/ephemeral_key.rs index 091da9c..6abef19 100644 --- a/src/models/ephemeral_key.rs +++ b/src/models/ephemeral_key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct EphemeralKey { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl EphemeralKey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution.rs b/src/models/execution.rs index 9591343..72ace97 100644 --- a/src/models/execution.rs +++ b/src/models/execution.rs @@ -8,27 +8,34 @@ use serde::{Deserialize, Serialize}; pub struct Execution { /// Execution ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Execution creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Execution update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution roles. #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Function or site ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Execution resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: crate::enums::ExecutionResourceType, /// Deployment ID used to create the execution. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// The trigger that caused the resource to execute. Possible values can be: - /// `http`, `schedule`, or `event`. + /// `http`, `schedule`, `event`, or `email`. #[serde(rename = "trigger")] pub trigger: crate::enums::ExecutionTrigger, /// The status of the resource execution. Possible values can be: `waiting`, @@ -37,39 +44,48 @@ pub struct Execution { pub status: crate::enums::ExecutionStatus, /// HTTP request method type. #[serde(rename = "requestMethod")] + #[serde(default = "default_request_method")] pub request_method: String, /// HTTP request path and query. #[serde(rename = "requestPath")] + #[serde(default = "default_request_path")] pub request_path: String, /// HTTP request headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "requestHeaders")] + #[serde(default = "default_request_headers")] pub request_headers: Vec, /// HTTP response status code. #[serde(rename = "responseStatusCode")] + #[serde(default = "default_response_status_code")] pub response_status_code: i64, /// HTTP response body. This will return empty unless execution is created as /// synchronous. #[serde(rename = "responseBody")] + #[serde(default = "default_response_body")] pub response_body: String, /// HTTP response headers as a key-value object. This will return only /// whitelisted headers. All headers are returned if execution is created as /// synchronous. #[serde(rename = "responseHeaders")] + #[serde(default = "default_response_headers")] pub response_headers: Vec, /// Resource logs. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Resource errors. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "errors")] + #[serde(default = "default_errors")] pub errors: String, - /// Resource(function/site) execution duration in seconds. + /// Total time the resource(function/site) took to respond, in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: f64, /// The scheduled time for execution. If left empty, execution will be queued /// immediately. @@ -78,6 +94,70 @@ pub struct Execution { pub scheduled_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> crate::enums::ExecutionResourceType { + serde_json::from_value(serde_json::json!("functions")).unwrap() +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_request_method() -> String { + "".to_string() +} + +fn default_request_path() -> String { + "".to_string() +} + +fn default_request_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_response_status_code() -> i64 { + 0 +} + +fn default_response_body() -> String { + "".to_string() +} + +fn default_response_headers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_errors() -> String { + "".to_string() +} + +fn default_duration() -> f64 { + 0.0 +} + impl Execution { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/execution_list.rs b/src/models/execution_list.rs index 85fa76f..d30bc6c 100644 --- a/src/models/execution_list.rs +++ b/src/models/execution_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ExecutionList { /// Total number of executions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of executions. #[serde(rename = "executions")] + #[serde(default = "default_executions")] pub executions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_executions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ExecutionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/file.rs b/src/models/file.rs index 1310f94..1f95426 100644 --- a/src/models/file.rs +++ b/src/models/file.rs @@ -8,58 +8,138 @@ use serde::{Deserialize, Serialize}; pub struct File { /// File ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Bucket ID. #[serde(rename = "bucketId")] + #[serde(default = "default_bucket_id")] pub bucket_id: String, /// File creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// File update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// File permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// File name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Virtual folder containing the file, with a trailing slash. Empty for the /// bucket root. #[serde(rename = "folder")] + #[serde(default = "default_folder")] pub folder: String, /// Full virtual path of the file: the folder followed by the file name. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// File MD5 signature. #[serde(rename = "signature")] + #[serde(default = "default_signature")] pub signature: String, /// File mime type. #[serde(rename = "mimeType")] + #[serde(default = "default_mime_type")] pub mime_type: String, /// File original size in bytes. #[serde(rename = "sizeOriginal")] + #[serde(default = "default_size_original")] pub size_original: i64, /// File actual stored size in bytes after compression and/or encryption. #[serde(rename = "sizeActual")] + #[serde(default = "default_size_actual")] pub size_actual: i64, /// Total number of chunks available #[serde(rename = "chunksTotal")] + #[serde(default = "default_chunks_total")] pub chunks_total: i64, /// Total number of chunks uploaded #[serde(rename = "chunksUploaded")] + #[serde(default = "default_chunks_uploaded")] pub chunks_uploaded: i64, /// Whether file contents are encrypted at rest. #[serde(rename = "encryption")] + #[serde(default = "default_encryption")] pub encryption: bool, /// Compression algorithm used for the file. Will be one of none, /// [gzip](https://en.wikipedia.org/wiki/Gzip), or /// [zstd](https://en.wikipedia.org/wiki/Zstd). #[serde(rename = "compression")] + #[serde(default = "default_compression")] pub compression: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_bucket_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_folder() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_signature() -> String { + "".to_string() +} + +fn default_mime_type() -> String { + "".to_string() +} + +fn default_size_original() -> i64 { + 0 +} + +fn default_size_actual() -> i64 { + 0 +} + +fn default_chunks_total() -> i64 { + 0 +} + +fn default_chunks_uploaded() -> i64 { + 0 +} + +fn default_encryption() -> bool { + false +} + +fn default_compression() -> String { + "none".to_string() +} + impl File { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/file_list.rs b/src/models/file_list.rs index bc9f598..06a0bec 100644 --- a/src/models/file_list.rs +++ b/src/models/file_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FileList { /// Total number of files that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of files. #[serde(rename = "files")] + #[serde(default = "default_files")] pub files: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_files() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FileList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/framework.rs b/src/models/framework.rs index fbc7a82..2f04803 100644 --- a/src/models/framework.rs +++ b/src/models/framework.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct Framework { /// Framework key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Framework Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Default runtime version. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// List of supported runtime versions. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, /// List of supported adapters. #[serde(rename = "adapters")] + #[serde(default = "default_adapters")] pub adapters: Vec, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_adapters() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Framework { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_adapter.rs b/src/models/framework_adapter.rs index 5ffe882..d945c32 100644 --- a/src/models/framework_adapter.rs +++ b/src/models/framework_adapter.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkAdapter { /// Adapter key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Default command to download dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// Default command to build site into output directory. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Default output directory of build. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Name of fallback file to use instead of 404 page. If null, Appwrite 404 /// page will be displayed. @@ -25,6 +29,22 @@ pub struct FrameworkAdapter { pub fallback_file: Option, } +fn default_key() -> String { + "".to_string() +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + impl FrameworkAdapter { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/framework_list.rs b/src/models/framework_list.rs index 9d8570f..fd7e484 100644 --- a/src/models/framework_list.rs +++ b/src/models/framework_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FrameworkList { /// Total number of frameworks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of frameworks. #[serde(rename = "frameworks")] + #[serde(default = "default_frameworks")] pub frameworks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_frameworks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FrameworkList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/function.rs b/src/models/function.rs index 06374cd..c4dc0dd 100644 --- a/src/models/function.rs +++ b/src/models/function.rs @@ -8,66 +8,85 @@ use serde::{Deserialize, Serialize}; pub struct Function { /// Function ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Function creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Function update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Execution permissions. #[serde(rename = "execute")] + #[serde(default = "default_execute")] pub execute: Vec, /// Function name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Function enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the function deployed with the latest configuration? This is set to /// false if you've changed an environment variables, entrypoint, commands, or /// other settings that needs redeploy to be applied. When the value is false, /// redeploy the function to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, executions will exclude logs and errors, and will be /// slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Function execution and build runtime. #[serde(rename = "runtime")] + #[serde(default = "default_runtime")] pub runtime: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Function's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Function's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Function variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Function trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Function execution schedule in CRON format. #[serde(rename = "schedule")] + #[serde(default = "default_schedule")] pub schedule: String, /// Minutes between scheduled executions. 0 when the function has no interval. #[serde(rename = "interval")] @@ -75,47 +94,197 @@ pub struct Function { pub interval: Option, /// Function execution timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The entrypoint file used to execute the deployment. #[serde(rename = "entrypoint")] + #[serde(default = "default_entrypoint")] pub entrypoint: String, /// The build command used to build the deployment. #[serde(rename = "commands")] + #[serde(default = "default_commands")] pub commands: String, /// Version of Open Runtimes used for the function. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Function VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to function in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, + /// Whether inbound email (SMTP) may trigger this function. Opt-in; default is + /// false. When disabled, recipients for this function are rejected. + #[serde(rename = "emailEnabled")] + #[serde(default = "default_email_enabled")] + pub email_enabled: bool, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_execute() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_runtime() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_schedule() -> String { + "".to_string() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_entrypoint() -> String { + "".to_string() +} + +fn default_commands() -> String { + "".to_string() +} + +fn default_version() -> String { + "v5".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_email_enabled() -> bool { + false } impl Function { @@ -289,6 +458,11 @@ impl Function { pub fn runtime_specification(&self) -> &String { &self.runtime_specification } + + /// Get email_enabled + pub fn email_enabled(&self) -> &bool { + &self.email_enabled + } } #[cfg(test)] @@ -330,6 +504,7 @@ mod tests { let _ = _model.provider_paths(); let _ = _model.build_specification(); let _ = _model.runtime_specification(); + let _ = _model.email_enabled(); } #[test] diff --git a/src/models/function_list.rs b/src/models/function_list.rs index ff9a37d..ee30315 100644 --- a/src/models/function_list.rs +++ b/src/models/function_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct FunctionList { /// Total number of functions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of functions. #[serde(rename = "functions")] + #[serde(default = "default_functions")] pub functions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_functions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl FunctionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/headers.rs b/src/models/headers.rs index 87a2b64..2aed2bc 100644 --- a/src/models/headers.rs +++ b/src/models/headers.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Headers { /// Header name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Header value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + impl Headers { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/identity.rs b/src/models/identity.rs index aca8541..bc00cf8 100644 --- a/src/models/identity.rs +++ b/src/models/identity.rs @@ -8,39 +8,93 @@ use serde::{Deserialize, Serialize}; pub struct Identity { /// Identity ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Identity creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Identity update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Identity Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// ID of the User in the Identity Provider. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Email of the User in the Identity Provider. #[serde(rename = "providerEmail")] + #[serde(default = "default_provider_email")] pub provider_email: String, /// Identity Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Identity Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// Identity Provider ID token (JWT) from the most recent native sign-in. Empty /// for identities created through the browser OAuth2 flow. #[serde(rename = "providerIdToken")] - #[serde(skip_serializing_if = "Option::is_none")] - pub provider_id_token: Option, + #[serde(default = "default_provider_id_token")] + pub provider_id_token: String, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_email() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_provider_id_token() -> String { + "".to_string() } impl Identity { @@ -94,15 +148,9 @@ impl Identity { &self.provider_refresh_token } - /// Set provider_id_token - pub fn set_provider_id_token(mut self, provider_id_token: String) -> Self { - self.provider_id_token = Some(provider_id_token); - self - } - /// Get provider_id_token - pub fn provider_id_token(&self) -> Option<&String> { - self.provider_id_token.as_ref() + pub fn provider_id_token(&self) -> &String { + &self.provider_id_token } } @@ -123,6 +171,7 @@ mod tests { let _ = _model.provider_access_token(); let _ = _model.provider_access_token_expiry(); let _ = _model.provider_refresh_token(); + let _ = _model.provider_id_token(); } #[test] diff --git a/src/models/identity_list.rs b/src/models/identity_list.rs index b8cca8a..951990d 100644 --- a/src/models/identity_list.rs +++ b/src/models/identity_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IdentityList { /// Total number of identities that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of identities. #[serde(rename = "identities")] + #[serde(default = "default_identities")] pub identities: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_identities() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IdentityList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/index.rs b/src/models/index.rs index d18b386..b3865e8 100644 --- a/src/models/index.rs +++ b/src/models/index.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Index { /// Index ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Index creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Index update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Index key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Index type. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Index status. Possible values: `available`, `processing`, `deleting`, /// `stuck`, or `failed` @@ -28,12 +33,15 @@ pub struct Index { /// Error message. Displays error generated on failure of creating or deleting /// an index. #[serde(rename = "error")] + #[serde(default = "default_error")] pub error: String, /// Index attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Index attributes length. #[serde(rename = "lengths")] + #[serde(default = "default_lengths")] pub lengths: Vec, /// Index orders. #[serde(rename = "orders")] @@ -41,6 +49,38 @@ pub struct Index { pub orders: Option>, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_error() -> String { + "".to_string() +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_lengths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Index { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/index_list.rs b/src/models/index_list.rs index 48eec9e..39499dc 100644 --- a/src/models/index_list.rs +++ b/src/models/index_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct IndexList { /// Total number of indexes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl IndexList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/insight.rs b/src/models/insight.rs index 937d6f7..e514aca 100644 --- a/src/models/insight.rs +++ b/src/models/insight.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct Insight { /// Insight ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Insight creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Insight update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Parent report ID. Insights always belong to a report. #[serde(rename = "reportId")] + #[serde(default = "default_report_id")] pub report_id: String, /// Insight type. One of databaseIndex (legacy), tablesDBIndex, /// documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, @@ -25,36 +29,46 @@ pub struct Insight { /// (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or /// vectorsDB.createIndex). #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Insight severity. One of info, warning, critical. #[serde(rename = "severity")] + #[serde(default = "default_severity")] pub severity: String, /// Insight status. One of active, dismissed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Type of the resource the insight is about. Plural noun, e.g. databases, /// sites, functions. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of the resource the insight is about. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Plural noun for the parent resource that contains the insight's resource, /// e.g. an insight about a column index on a table → resourceType=indexes, /// parentResourceType=tables. Empty when the resource has no parent. #[serde(rename = "parentResourceType")] + #[serde(default = "default_parent_resource_type")] pub parent_resource_type: String, /// ID of the parent resource. Empty when the resource has no parent. #[serde(rename = "parentResourceId")] + #[serde(default = "default_parent_resource_id")] pub parent_resource_id: String, /// Insight title. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Short markdown summary describing the insight. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// List of call-to-action buttons attached to this insight. #[serde(rename = "ctas")] + #[serde(default = "default_ctas")] pub ctas: Vec, /// Time the insight was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -71,6 +85,62 @@ pub struct Insight { pub dismissed_by: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_report_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_severity() -> String { + "info".to_string() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_parent_resource_type() -> String { + "".to_string() +} + +fn default_parent_resource_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_ctas() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Insight { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/insight_cta.rs b/src/models/insight_cta.rs index 6a3b719..d96fa8a 100644 --- a/src/models/insight_cta.rs +++ b/src/models/insight_cta.rs @@ -8,24 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct InsightCTA { /// Human-readable label for the CTA, used in UI. #[serde(rename = "label")] + #[serde(default = "default_label")] pub label: String, /// Public API service (SDK namespace) the client should invoke. Must match the /// engine that owns the resource — for index suggestions: databases /// (legacy), tablesDB, documentsDB, or vectorsDB. #[serde(rename = "service")] + #[serde(default = "default_service")] pub service: String, /// Public API method on the chosen service the client should invoke when this /// CTA is triggered. #[serde(rename = "method")] + #[serde(default = "default_method")] pub method: String, /// Parameter map the client should pass to the service method when this CTA is /// triggered. Keys match the target API's parameter names (e.g. /// databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes /// for the legacy Databases API). #[serde(rename = "params")] + #[serde(default = "default_params")] pub params: serde_json::Value, } +fn default_label() -> String { + "".to_string() +} + +fn default_service() -> String { + "".to_string() +} + +fn default_method() -> String { + "".to_string() +} + +fn default_params() -> serde_json::Value { + serde_json::json!({}) +} + impl InsightCTA { /// Get label pub fn label(&self) -> &String { diff --git a/src/models/insight_list.rs b/src/models/insight_list.rs index 54b229c..e5b6d1a 100644 --- a/src/models/insight_list.rs +++ b/src/models/insight_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct InsightList { /// Total number of insights that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of insights. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl InsightList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/jwt.rs b/src/models/jwt.rs index 8482207..535cf61 100644 --- a/src/models/jwt.rs +++ b/src/models/jwt.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Jwt { /// JWT encoded string. #[serde(rename = "jwt")] + #[serde(default = "default_jwt")] pub jwt: String, } +fn default_jwt() -> String { + "".to_string() +} + impl Jwt { /// Get jwt pub fn jwt(&self) -> &String { diff --git a/src/models/key.rs b/src/models/key.rs index 109b8d5..06b83c7 100644 --- a/src/models/key.rs +++ b/src/models/key.rs @@ -8,34 +8,79 @@ use serde::{Deserialize, Serialize}; pub struct Key { /// Key ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Key creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Key update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Key name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Key expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Secret key. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// List of SDK user agents that used this key. #[serde(rename = "sdks")] + #[serde(default = "default_sdks")] pub sdks: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + +fn default_sdks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Key { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/key_list.rs b/src/models/key_list.rs index 0cad143..767cf5e 100644 --- a/src/models/key_list.rs +++ b/src/models/key_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct KeyList { /// Total number of keys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of keys. #[serde(rename = "keys")] + #[serde(default = "default_keys")] pub keys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_keys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl KeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/language.rs b/src/models/language.rs index bef7ec4..fd3d530 100644 --- a/src/models/language.rs +++ b/src/models/language.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Language { /// Language name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Language two-character ISO 639-1 codes. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Language native name. #[serde(rename = "nativeName")] + #[serde(default = "default_native_name")] pub native_name: String, } +fn default_name() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + +fn default_native_name() -> String { + "".to_string() +} + impl Language { /// Get name pub fn name(&self) -> &String { diff --git a/src/models/language_list.rs b/src/models/language_list.rs index 42d79d9..9993952 100644 --- a/src/models/language_list.rs +++ b/src/models/language_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LanguageList { /// Total number of languages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of languages. #[serde(rename = "languages")] + #[serde(default = "default_languages")] pub languages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_languages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LanguageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/locale.rs b/src/models/locale.rs index 08b7f02..ecd0d0d 100644 --- a/src/models/locale.rs +++ b/src/models/locale.rs @@ -8,28 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Locale { /// User IP address. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) /// two-character format #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. This field support localization. #[serde(rename = "country")] + #[serde(default = "default_country")] pub country: String, /// Continent code. A two character continent code "AF" for Africa, "AN" for /// Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" /// for Oceania, and "SA" for South America. #[serde(rename = "continentCode")] + #[serde(default = "default_continent_code")] pub continent_code: String, /// Continent name. This field support localization. #[serde(rename = "continent")] + #[serde(default = "default_continent")] pub continent: String, /// True if country is part of the European Union. #[serde(rename = "eu")] + #[serde(default = "default_eu")] pub eu: bool, /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) /// three-character format #[serde(rename = "currency")] + #[serde(default = "default_currency")] pub currency: String, /// City #[serde(rename = "city")] @@ -77,6 +84,34 @@ pub struct Locale { pub connection_organization: Option, } +fn default_ip() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country() -> String { + "".to_string() +} + +fn default_continent_code() -> String { + "".to_string() +} + +fn default_continent() -> String { + "".to_string() +} + +fn default_eu() -> bool { + false +} + +fn default_currency() -> String { + "".to_string() +} + impl Locale { /// Get ip pub fn ip(&self) -> &String { diff --git a/src/models/locale_code.rs b/src/models/locale_code.rs index 389f8a2..84b8601 100644 --- a/src/models/locale_code.rs +++ b/src/models/locale_code.rs @@ -9,12 +9,22 @@ pub struct LocaleCode { /// Locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Locale name #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + impl LocaleCode { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/locale_code_list.rs b/src/models/locale_code_list.rs index e8e2ebb..8314d75 100644 --- a/src/models/locale_code_list.rs +++ b/src/models/locale_code_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct LocaleCodeList { /// Total number of localeCodes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of localeCodes. #[serde(rename = "localeCodes")] + #[serde(default = "default_locale_codes")] pub locale_codes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_locale_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl LocaleCodeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/log.rs b/src/models/log.rs deleted file mode 100644 index c62709d..0000000 --- a/src/models/log.rs +++ /dev/null @@ -1,235 +0,0 @@ -//! Log model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Log -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct Log { - /// Event name. - #[serde(rename = "event")] - pub event: String, - /// User ID of the actor recorded for this log. During impersonation, this is - /// the original impersonator, not the impersonated target user. - #[serde(rename = "userId")] - pub user_id: String, - /// User email of the actor recorded for this log. During impersonation, this - /// is the original impersonator. - #[serde(rename = "userEmail")] - pub user_email: String, - /// User name of the actor recorded for this log. During impersonation, this is - /// the original impersonator. - #[serde(rename = "userName")] - pub user_name: String, - /// API mode when event triggered. - #[serde(rename = "mode")] - pub mode: String, - /// User type who triggered the audit log. Possible values: user, admin, guest, - /// hidden, keyProject, keyAccount, keyOrganization. - #[serde(rename = "userType")] - pub user_type: String, - /// IP session in use when the session was created. - #[serde(rename = "ip")] - pub ip: String, - /// Log creation date in ISO 8601 format. - #[serde(rename = "time")] - pub time: String, - /// Operating system code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - #[serde(rename = "osCode")] - pub os_code: String, - /// Operating system name. - #[serde(rename = "osName")] - pub os_name: String, - /// Operating system version. - #[serde(rename = "osVersion")] - pub os_version: String, - /// Client type. - #[serde(rename = "clientType")] - pub client_type: String, - /// Client code name. View list of [available - /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - #[serde(rename = "clientCode")] - pub client_code: String, - /// Client name. - #[serde(rename = "clientName")] - pub client_name: String, - /// Client version. - #[serde(rename = "clientVersion")] - pub client_version: String, - /// Client engine name. - #[serde(rename = "clientEngine")] - pub client_engine: String, - /// Client engine name. - #[serde(rename = "clientEngineVersion")] - pub client_engine_version: String, - /// Device name. - #[serde(rename = "deviceName")] - pub device_name: String, - /// Device brand name. - #[serde(rename = "deviceBrand")] - pub device_brand: String, - /// Device model name. - #[serde(rename = "deviceModel")] - pub device_model: String, - /// Country two-character ISO 3166-1 alpha code. - #[serde(rename = "countryCode")] - pub country_code: String, - /// Country name. - #[serde(rename = "countryName")] - pub country_name: String, -} - -impl Log { - /// Get event - pub fn event(&self) -> &String { - &self.event - } - - /// Get user_id - pub fn user_id(&self) -> &String { - &self.user_id - } - - /// Get user_email - pub fn user_email(&self) -> &String { - &self.user_email - } - - /// Get user_name - pub fn user_name(&self) -> &String { - &self.user_name - } - - /// Get mode - pub fn mode(&self) -> &String { - &self.mode - } - - /// Get user_type - pub fn user_type(&self) -> &String { - &self.user_type - } - - /// Get ip - pub fn ip(&self) -> &String { - &self.ip - } - - /// Get time - pub fn time(&self) -> &String { - &self.time - } - - /// Get os_code - pub fn os_code(&self) -> &String { - &self.os_code - } - - /// Get os_name - pub fn os_name(&self) -> &String { - &self.os_name - } - - /// Get os_version - pub fn os_version(&self) -> &String { - &self.os_version - } - - /// Get client_type - pub fn client_type(&self) -> &String { - &self.client_type - } - - /// Get client_code - pub fn client_code(&self) -> &String { - &self.client_code - } - - /// Get client_name - pub fn client_name(&self) -> &String { - &self.client_name - } - - /// Get client_version - pub fn client_version(&self) -> &String { - &self.client_version - } - - /// Get client_engine - pub fn client_engine(&self) -> &String { - &self.client_engine - } - - /// Get client_engine_version - pub fn client_engine_version(&self) -> &String { - &self.client_engine_version - } - - /// Get device_name - pub fn device_name(&self) -> &String { - &self.device_name - } - - /// Get device_brand - pub fn device_brand(&self) -> &String { - &self.device_brand - } - - /// Get device_model - pub fn device_model(&self) -> &String { - &self.device_model - } - - /// Get country_code - pub fn country_code(&self) -> &String { - &self.country_code - } - - /// Get country_name - pub fn country_name(&self) -> &String { - &self.country_name - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_creation() { - let _model = ::default(); - let _ = _model.event(); - let _ = _model.user_id(); - let _ = _model.user_email(); - let _ = _model.user_name(); - let _ = _model.mode(); - let _ = _model.user_type(); - let _ = _model.ip(); - let _ = _model.time(); - let _ = _model.os_code(); - let _ = _model.os_name(); - let _ = _model.os_version(); - let _ = _model.client_type(); - let _ = _model.client_code(); - let _ = _model.client_name(); - let _ = _model.client_version(); - let _ = _model.client_engine(); - let _ = _model.client_engine_version(); - let _ = _model.device_name(); - let _ = _model.device_brand(); - let _ = _model.device_model(); - let _ = _model.country_code(); - let _ = _model.country_name(); - } - - #[test] - fn test_log_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/log_list.rs b/src/models/log_list.rs deleted file mode 100644 index 8215ec2..0000000 --- a/src/models/log_list.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! LogList model for Appwrite SDK - -use serde::{Deserialize, Serialize}; - -/// Logs List -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(test, derive(Default))] -pub struct LogList { - /// Total number of logs that matched your query. - #[serde(rename = "total")] - pub total: i64, - /// List of logs. - #[serde(rename = "logs")] - pub logs: Vec, -} - -impl LogList { - /// Get total - pub fn total(&self) -> &i64 { - &self.total - } - - /// Get logs - pub fn logs(&self) -> &Vec { - &self.logs - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_log_list_creation() { - let _model = ::default(); - let _ = _model.total(); - let _ = _model.logs(); - } - - #[test] - fn test_log_list_serialization() { - let model = ::default(); - let json = serde_json::to_string(&model); - assert!(json.is_ok()); - - let deserialized: Result = serde_json::from_str(&json.unwrap()); - assert!(deserialized.is_ok()); - } -} diff --git a/src/models/membership.rs b/src/models/membership.rs index da724ca..bc0954e 100644 --- a/src/models/membership.rs +++ b/src/models/membership.rs @@ -8,59 +8,134 @@ use serde::{Deserialize, Serialize}; pub struct Membership { /// Membership ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Membership creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Membership update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User name. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// User email address. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: String, /// User phone number. Hide this attribute by toggling membership privacy in /// the Console. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: String, /// Team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Team name. #[serde(rename = "teamName")] + #[serde(default = "default_team_name")] pub team_name: String, /// Date, the user has been invited to join the team in ISO 8601 format. #[serde(rename = "invited")] + #[serde(default = "default_invited")] pub invited: String, /// Date, the user has accepted the invitation to join the team in ISO 8601 /// format. #[serde(rename = "joined")] + #[serde(default = "default_joined")] pub joined: String, /// User confirmation status, true if the user has joined the team or false /// otherwise. #[serde(rename = "confirm")] + #[serde(default = "default_confirm")] pub confirm: bool, /// Multi factor authentication status, true if the user has MFA enabled or /// false otherwise. Hide this attribute by toggling membership privacy in the /// Console. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// Most recent access date in ISO 8601 format. Show this attribute by toggling /// membership privacy in the Console. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: String, /// User list of roles #[serde(rename = "roles")] + #[serde(default = "default_roles")] pub roles: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_user_email() -> String { + "".to_string() +} + +fn default_user_phone() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_team_name() -> String { + "".to_string() +} + +fn default_invited() -> String { + "".to_string() +} + +fn default_joined() -> String { + "".to_string() +} + +fn default_confirm() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> String { + "".to_string() +} + +fn default_roles() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Membership { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/membership_list.rs b/src/models/membership_list.rs index 628a569..a5c2d03 100644 --- a/src/models/membership_list.rs +++ b/src/models/membership_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MembershipList { /// Total number of memberships that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of memberships. #[serde(rename = "memberships")] + #[serde(default = "default_memberships")] pub memberships: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_memberships() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MembershipList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/message.rs b/src/models/message.rs index 554149b..29880eb 100644 --- a/src/models/message.rs +++ b/src/models/message.rs @@ -8,24 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Message { /// Message ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Message creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Message update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Message provider type. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// Topic IDs set as recipients. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, /// User IDs set as recipients. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, /// Target IDs set as recipients. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// The scheduled time for message. #[serde(rename = "scheduledAt")] @@ -41,15 +48,58 @@ pub struct Message { pub delivery_errors: Option>, /// Number of recipients the message was delivered to. #[serde(rename = "deliveredTotal")] + #[serde(default = "default_delivered_total")] pub delivered_total: i64, /// Data of the message. #[serde(rename = "data")] + #[serde(default = "default_data")] pub data: serde_json::Value, /// Status of delivery. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::MessageStatus, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_delivered_total() -> i64 { + 0 +} + +fn default_data() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_status() -> crate::enums::MessageStatus { + serde_json::from_value(serde_json::json!("draft")).unwrap() +} + impl Message { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/message_list.rs b/src/models/message_list.rs index de470cb..628ae06 100644 --- a/src/models/message_list.rs +++ b/src/models/message_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MessageList { /// Total number of messages that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of messages. #[serde(rename = "messages")] + #[serde(default = "default_messages")] pub messages: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_messages() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MessageList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mfa_challenge.rs b/src/models/mfa_challenge.rs index cee280b..ce8a91a 100644 --- a/src/models/mfa_challenge.rs +++ b/src/models/mfa_challenge.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallenge { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl MfaChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_challenge_secret.rs b/src/models/mfa_challenge_secret.rs index 42a9c6e..e21b3ae 100644 --- a/src/models/mfa_challenge_secret.rs +++ b/src/models/mfa_challenge_secret.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaChallengeSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Challenge code to be delivered to the end user through a custom channel. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_code() -> String { + "".to_string() +} + impl MfaChallengeSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/mfa_factors.rs b/src/models/mfa_factors.rs index 14b1ebf..6415f45 100644 --- a/src/models/mfa_factors.rs +++ b/src/models/mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct MfaFactors { /// Can TOTP be used for MFA challenge for this account. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Can phone (SMS) be used for MFA challenge for this account. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Can email be used for MFA challenge for this account. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Can recovery code be used for MFA challenge for this account. #[serde(rename = "recoveryCode")] + #[serde(default = "default_recovery_code")] pub recovery_code: bool, /// Can custom factor be used for MFA challenge for this account. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_totp() -> bool { + false +} + +fn default_phone() -> bool { + false +} + +fn default_email() -> bool { + false +} + +fn default_recovery_code() -> bool { + false +} + +fn default_custom() -> bool { + false +} + impl MfaFactors { /// Get totp pub fn totp(&self) -> &bool { diff --git a/src/models/mfa_recovery_codes.rs b/src/models/mfa_recovery_codes.rs index 44f77a3..c9089ef 100644 --- a/src/models/mfa_recovery_codes.rs +++ b/src/models/mfa_recovery_codes.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct MfaRecoveryCodes { /// Recovery codes. #[serde(rename = "recoveryCodes")] + #[serde(default = "default_recovery_codes")] pub recovery_codes: Vec, } +fn default_recovery_codes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MfaRecoveryCodes { /// Get recovery_codes pub fn recovery_codes(&self) -> &Vec { diff --git a/src/models/mfa_type.rs b/src/models/mfa_type.rs index 7809d95..69e7a79 100644 --- a/src/models/mfa_type.rs +++ b/src/models/mfa_type.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MfaType { /// Secret token used for TOTP factor. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// URI for authenticator apps. #[serde(rename = "uri")] + #[serde(default = "default_uri")] pub uri: String, } +fn default_secret() -> String { + "".to_string() +} + +fn default_uri() -> String { + "".to_string() +} + impl MfaType { /// Get secret pub fn secret(&self) -> &String { diff --git a/src/models/mock_number.rs b/src/models/mock_number.rs index 1d8ea85..0a7244c 100644 --- a/src/models/mock_number.rs +++ b/src/models/mock_number.rs @@ -9,18 +9,38 @@ pub struct MockNumber { /// Mock phone number for testing phone authentication. Useful for testing /// phone authentication without sending an SMS. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: String, /// Mock OTP for the number. #[serde(rename = "otp")] + #[serde(default = "default_otp")] pub otp: String, /// Attribute creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Attribute update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, } +fn default_number() -> String { + "".to_string() +} + +fn default_otp() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + impl MockNumber { /// Get number pub fn number(&self) -> &String { diff --git a/src/models/mock_number_list.rs b/src/models/mock_number_list.rs index b4d7f7f..44de93f 100644 --- a/src/models/mock_number_list.rs +++ b/src/models/mock_number_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct MockNumberList { /// Total number of mockNumbers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of mockNumbers. #[serde(rename = "mockNumbers")] + #[serde(default = "default_mock_numbers")] pub mock_numbers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_mock_numbers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl MockNumberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/mod.rs b/src/models/mod.rs index 8c4e935..1eb0426 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -22,8 +22,6 @@ pub mod session_list; pub use session_list::SessionList; pub mod identity_list; pub use identity_list::IdentityList; -pub mod log_list; -pub use log_list::LogList; pub mod file_list; pub use file_list::FileList; pub mod bucket_list; @@ -196,8 +194,6 @@ pub mod document; pub use document::Document; pub mod presence; pub use presence::Presence; -pub mod log; -pub use log::Log; pub mod user; pub use user::User; pub mod algo_md5; @@ -268,8 +264,6 @@ pub mod key; pub use key::Key; pub mod ephemeral_key; pub use ephemeral_key::EphemeralKey; -pub mod dev_key; -pub use dev_key::DevKey; pub mod mock_number; pub use mock_number::MockNumber; pub mod o_auth2_github; @@ -396,6 +390,14 @@ pub mod policy_mfa_factors; pub use policy_mfa_factors::PolicyMfaFactors; pub mod policy_passkey; pub use policy_passkey::PolicyPasskey; +pub mod policy_deny_aliased_email; +pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; +pub mod policy_deny_disposable_email; +pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; +pub mod policy_deny_free_email; +pub use policy_deny_free_email::PolicyDenyFreeEmail; +pub mod policy_deny_corporate_email; +pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod platform_web; pub use platform_web::PlatformWeb; pub mod platform_apple; @@ -534,14 +536,6 @@ pub mod dedicated_database_pitr_windows; pub use dedicated_database_pitr_windows::DedicatedDatabasePITRWindows; pub mod backup_policy; pub use backup_policy::BackupPolicy; -pub mod policy_deny_aliased_email; -pub use policy_deny_aliased_email::PolicyDenyAliasedEmail; -pub mod policy_deny_disposable_email; -pub use policy_deny_disposable_email::PolicyDenyDisposableEmail; -pub mod policy_deny_free_email; -pub use policy_deny_free_email::PolicyDenyFreeEmail; -pub mod policy_deny_corporate_email; -pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; pub mod dedicated_database_pooler; pub use dedicated_database_pooler::DedicatedDatabasePooler; pub mod postgres_extension; @@ -556,8 +550,6 @@ pub mod dedicated_database_specification; pub use dedicated_database_specification::DedicatedDatabaseSpecification; pub mod dedicated_database_specification_list; pub use dedicated_database_specification_list::DedicatedDatabaseSpecificationList; -pub mod dedicated_database_specification_pricing; -pub use dedicated_database_specification_pricing::DedicatedDatabaseSpecificationPricing; pub mod database_status_connections; pub use database_status_connections::DatabaseStatusConnections; pub mod database_status_replica; @@ -669,7 +661,6 @@ impl Model for ColumnIndexList {} impl Model for UserList {} impl Model for SessionList {} impl Model for IdentityList {} -impl Model for LogList {} impl Model for FileList {} impl Model for BucketList {} impl Model for ResourceTokenList {} @@ -756,7 +747,6 @@ impl Model for ColumnIndex {} impl Model for Row {} impl Model for Document {} impl Model for Presence {} -impl Model for Log {} impl Model for User {} impl Model for AlgoMd5 {} impl Model for AlgoSha {} @@ -792,7 +782,6 @@ impl Model for ProjectProtocol {} impl Model for Webhook {} impl Model for Key {} impl Model for EphemeralKey {} -impl Model for DevKey {} impl Model for MockNumber {} impl Model for OAuth2Github {} impl Model for OAuth2Discord {} @@ -856,6 +845,10 @@ impl Model for PolicyUserLimit {} impl Model for PolicyMembershipPrivacy {} impl Model for PolicyMfaFactors {} impl Model for PolicyPasskey {} +impl Model for PolicyDenyAliasedEmail {} +impl Model for PolicyDenyDisposableEmail {} +impl Model for PolicyDenyFreeEmail {} +impl Model for PolicyDenyCorporateEmail {} impl Model for PlatformWeb {} impl Model for PlatformApple {} impl Model for PlatformAndroid {} @@ -925,10 +918,6 @@ impl Model for ProxyInvalidation {} impl Model for Organization {} impl Model for DedicatedDatabasePITRWindows {} impl Model for BackupPolicy {} -impl Model for PolicyDenyAliasedEmail {} -impl Model for PolicyDenyDisposableEmail {} -impl Model for PolicyDenyFreeEmail {} -impl Model for PolicyDenyCorporateEmail {} impl Model for DedicatedDatabasePooler {} impl Model for PostgresExtension {} impl Model for Program {} @@ -936,7 +925,6 @@ impl Model for BackupRestoration {} impl Model for DedicatedDatabaseRestorationList {} impl Model for DedicatedDatabaseSpecification {} impl Model for DedicatedDatabaseSpecificationList {} -impl Model for DedicatedDatabaseSpecificationPricing {} impl Model for DatabaseStatusConnections {} impl Model for DatabaseStatusReplica {} impl Model for DatabaseStatusVolume {} diff --git a/src/models/o_auth2_amazon.rs b/src/models/o_auth2_amazon.rs index c2359b9..6e79642 100644 --- a/src/models/o_auth2_amazon.rs +++ b/src/models/o_auth2_amazon.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Amazon { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Amazon OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Amazon OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Amazon { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_apple.rs b/src/models/o_auth2_apple.rs index 5022915..3b357f7 100644 --- a/src/models/o_auth2_apple.rs +++ b/src/models/o_auth2_apple.rs @@ -8,34 +8,72 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Apple { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Apple OAuth2 service ID. #[serde(rename = "serviceId")] + #[serde(default = "default_service_id")] pub service_id: String, /// Apple OAuth2 key ID. #[serde(rename = "keyId")] + #[serde(default = "default_key_id")] pub key_id: String, /// Apple OAuth2 team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Apple OAuth2 .p8 private key file contents. The secret key wrapped by the /// PEM markers is 200 characters long. #[serde(rename = "p8File")] + #[serde(default = "default_p8_file")] pub p8_file: String, /// Native Sign in with Apple is active and can be used to create sessions from /// an ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// App bundle IDs accepted as ID token audiences for native Sign in with /// Apple, next to the Services ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_service_id() -> String { + "".to_string() +} + +fn default_key_id() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_p8_file() -> String { + "".to_string() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Apple { @@ -69,26 +107,14 @@ impl OAuth2Apple { &self.p8_file } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -105,6 +131,8 @@ mod tests { let _ = _model.key_id(); let _ = _model.team_id(); let _ = _model.p8_file(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_appwrite.rs b/src/models/o_auth2_appwrite.rs index 4ca0449..54ce0c8 100644 --- a/src/models/o_auth2_appwrite.rs +++ b/src/models/o_auth2_appwrite.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Appwrite { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Appwrite OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Appwrite OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Appwrite { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_auth0.rs b/src/models/o_auth2_auth0.rs index 12a3426..c974616 100644 --- a/src/models/o_auth2_auth0.rs +++ b/src/models/o_auth2_auth0.rs @@ -8,25 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Auth0 { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Auth0 OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Auth0 OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Auth0 OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Auth0 OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Auth0 { /// Get id pub fn id(&self) -> &String { @@ -48,15 +77,9 @@ impl OAuth2Auth0 { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get endpoint @@ -76,6 +99,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.endpoint(); } diff --git a/src/models/o_auth2_authentik.rs b/src/models/o_auth2_authentik.rs index da60963..8a4735b 100644 --- a/src/models/o_auth2_authentik.rs +++ b/src/models/o_auth2_authentik.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Authentik { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Authentik OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Authentik OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Authentik OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Authentik { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_autodesk.rs b/src/models/o_auth2_autodesk.rs index a487d8a..2f30585 100644 --- a/src/models/o_auth2_autodesk.rs +++ b/src/models/o_auth2_autodesk.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Autodesk { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Autodesk OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Autodesk OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Autodesk { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitbucket.rs b/src/models/o_auth2_bitbucket.rs index cfe595b..1694254 100644 --- a/src/models/o_auth2_bitbucket.rs +++ b/src/models/o_auth2_bitbucket.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitbucket { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitbucket OAuth2 key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Bitbucket OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + impl OAuth2Bitbucket { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_bitly.rs b/src/models/o_auth2_bitly.rs index 15a0774..1f0d383 100644 --- a/src/models/o_auth2_bitly.rs +++ b/src/models/o_auth2_bitly.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Bitly { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Bitly OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Bitly OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Bitly { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_box.rs b/src/models/o_auth2_box.rs index 83959c8..c2fefe6 100644 --- a/src/models/o_auth2_box.rs +++ b/src/models/o_auth2_box.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Box { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Box OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Box OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Box { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_cloudflare.rs b/src/models/o_auth2_cloudflare.rs index 3f6703f..6c977c2 100644 --- a/src/models/o_auth2_cloudflare.rs +++ b/src/models/o_auth2_cloudflare.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Cloudflare { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Cloudflare OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Cloudflare OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Cloudflare { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dailymotion.rs b/src/models/o_auth2_dailymotion.rs index b94e6bc..795a455 100644 --- a/src/models/o_auth2_dailymotion.rs +++ b/src/models/o_auth2_dailymotion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dailymotion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dailymotion OAuth2 API key. #[serde(rename = "apiKey")] + #[serde(default = "default_api_key")] pub api_key: String, /// Dailymotion OAuth2 API secret. #[serde(rename = "apiSecret")] + #[serde(default = "default_api_secret")] pub api_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_api_key() -> String { + "".to_string() +} + +fn default_api_secret() -> String { + "".to_string() +} + impl OAuth2Dailymotion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_discord.rs b/src/models/o_auth2_discord.rs index 91a601b..9c0c58d 100644 --- a/src/models/o_auth2_discord.rs +++ b/src/models/o_auth2_discord.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Discord { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Discord OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Discord OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Discord OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Discord { @@ -45,15 +69,9 @@ impl OAuth2Discord { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_disqus.rs b/src/models/o_auth2_disqus.rs index 467e840..957c4f6 100644 --- a/src/models/o_auth2_disqus.rs +++ b/src/models/o_auth2_disqus.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Disqus { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Disqus OAuth2 public key. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: String, /// Disqus OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_public_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Disqus { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_dropbox.rs b/src/models/o_auth2_dropbox.rs index d566903..9160dbd 100644 --- a/src/models/o_auth2_dropbox.rs +++ b/src/models/o_auth2_dropbox.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Dropbox { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Dropbox OAuth2 app key. #[serde(rename = "appKey")] + #[serde(default = "default_app_key")] pub app_key: String, /// Dropbox OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_key() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Dropbox { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_etsy.rs b/src/models/o_auth2_etsy.rs index cf6bab9..a0158a0 100644 --- a/src/models/o_auth2_etsy.rs +++ b/src/models/o_auth2_etsy.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Etsy { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Etsy OAuth2 keystring. #[serde(rename = "keyString")] + #[serde(default = "default_key_string")] pub key_string: String, /// Etsy OAuth2 shared secret. #[serde(rename = "sharedSecret")] + #[serde(default = "default_shared_secret")] pub shared_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_key_string() -> String { + "".to_string() +} + +fn default_shared_secret() -> String { + "".to_string() +} + impl OAuth2Etsy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_facebook.rs b/src/models/o_auth2_facebook.rs index c8c3bd9..7cabbef 100644 --- a/src/models/o_auth2_facebook.rs +++ b/src/models/o_auth2_facebook.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Facebook { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Facebook OAuth2 app ID. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Facebook OAuth2 app secret. #[serde(rename = "appSecret")] + #[serde(default = "default_app_secret")] pub app_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_app_secret() -> String { + "".to_string() +} + impl OAuth2Facebook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_figma.rs b/src/models/o_auth2_figma.rs index 0ef3e3b..99c241c 100644 --- a/src/models/o_auth2_figma.rs +++ b/src/models/o_auth2_figma.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Figma { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Figma OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Figma OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Figma { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_fusion_auth.rs b/src/models/o_auth2_fusion_auth.rs index 2222752..a9a7122 100644 --- a/src/models/o_auth2_fusion_auth.rs +++ b/src/models/o_auth2_fusion_auth.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2FusionAuth { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// FusionAuth OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// FusionAuth OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// FusionAuth OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2FusionAuth { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_github.rs b/src/models/o_auth2_github.rs index 1be7953..684abde 100644 --- a/src/models/o_auth2_github.rs +++ b/src/models/o_auth2_github.rs @@ -8,21 +8,45 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Github { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App /// ID and client ID are available. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// GitHub OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// GitHub OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Github { @@ -46,15 +70,9 @@ impl OAuth2Github { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -69,6 +87,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_gitlab.rs b/src/models/o_auth2_gitlab.rs index 8444d1b..fa76ce7 100644 --- a/src/models/o_auth2_gitlab.rs +++ b/src/models/o_auth2_gitlab.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Gitlab { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// GitLab OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// GitLab OAuth2 secret. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted /// instances. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl OAuth2Gitlab { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_google.rs b/src/models/o_auth2_google.rs index ece34e2..e9261a9 100644 --- a/src/models/o_auth2_google.rs +++ b/src/models/o_auth2_google.rs @@ -8,30 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Google { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Google OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Google OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Google OAuth2 prompt values. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: Vec, /// Native Google sign-in is active and can be used to create sessions from an /// ID token. Independent of enabled, which only controls the browser-based /// flow. #[serde(rename = "nativeEnabled")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_enabled: Option, + #[serde(default = "default_native_enabled")] + pub native_enabled: bool, /// Additional OAuth2 client IDs accepted as ID token audiences for native /// sign-in, next to the client ID. #[serde(rename = "nativeClientIds")] - #[serde(skip_serializing_if = "Option::is_none")] - pub native_client_ids: Option>, + #[serde(default = "default_native_client_ids")] + pub native_client_ids: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!(["consent"])).unwrap() +} + +fn default_native_enabled() -> bool { + false +} + +fn default_native_client_ids() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Google { @@ -60,26 +93,14 @@ impl OAuth2Google { &self.prompt } - /// Set native_enabled - pub fn set_native_enabled(mut self, native_enabled: bool) -> Self { - self.native_enabled = Some(native_enabled); - self - } - /// Get native_enabled - pub fn native_enabled(&self) -> Option<&bool> { - self.native_enabled.as_ref() - } - - /// Set native_client_ids - pub fn set_native_client_ids(mut self, native_client_ids: Vec) -> Self { - self.native_client_ids = Some(native_client_ids); - self + pub fn native_enabled(&self) -> &bool { + &self.native_enabled } /// Get native_client_ids - pub fn native_client_ids(&self) -> Option<&Vec> { - self.native_client_ids.as_ref() + pub fn native_client_ids(&self) -> &Vec { + &self.native_client_ids } } @@ -95,6 +116,8 @@ mod tests { let _ = _model.client_id(); let _ = _model.client_secret(); let _ = _model.prompt(); + let _ = _model.native_enabled(); + let _ = _model.native_client_ids(); } #[test] diff --git a/src/models/o_auth2_hugging_face.rs b/src/models/o_auth2_hugging_face.rs index 6259543..43b9831 100644 --- a/src/models/o_auth2_hugging_face.rs +++ b/src/models/o_auth2_hugging_face.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2HuggingFace { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Hugging Face OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Hugging Face OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2HuggingFace { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_keycloak.rs b/src/models/o_auth2_keycloak.rs index 1586924..b5fd439 100644 --- a/src/models/o_auth2_keycloak.rs +++ b/src/models/o_auth2_keycloak.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Keycloak { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Keycloak OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Keycloak OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Keycloak OAuth2 endpoint domain. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, /// Keycloak OAuth2 realm name. #[serde(rename = "realmName")] + #[serde(default = "default_realm_name")] pub realm_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + +fn default_realm_name() -> String { + "".to_string() +} + impl OAuth2Keycloak { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_kick.rs b/src/models/o_auth2_kick.rs index d3f982f..12376b0 100644 --- a/src/models/o_auth2_kick.rs +++ b/src/models/o_auth2_kick.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Kick { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Kick OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Kick OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Kick { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_linkedin.rs b/src/models/o_auth2_linkedin.rs index 1c1077e..e76011f 100644 --- a/src/models/o_auth2_linkedin.rs +++ b/src/models/o_auth2_linkedin.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Linkedin { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// LinkedIn OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// LinkedIn OAuth2 primary client secret. #[serde(rename = "primaryClientSecret")] + #[serde(default = "default_primary_client_secret")] pub primary_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_primary_client_secret() -> String { + "".to_string() +} + impl OAuth2Linkedin { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_microsoft.rs b/src/models/o_auth2_microsoft.rs index 3a2535b..3aab893 100644 --- a/src/models/o_auth2_microsoft.rs +++ b/src/models/o_auth2_microsoft.rs @@ -8,26 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Microsoft { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Microsoft OAuth2 application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// Microsoft OAuth2 application secret. #[serde(rename = "applicationSecret")] + #[serde(default = "default_application_secret")] pub application_secret: String, /// Microsoft OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Microsoft Entra ID tenant identifier. Use 'common', 'organizations', /// 'consumers' or a specific tenant ID. #[serde(rename = "tenant")] + #[serde(default = "default_tenant")] pub tenant: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_application_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tenant() -> String { + "".to_string() +} + impl OAuth2Microsoft { /// Get id pub fn id(&self) -> &String { @@ -49,15 +78,9 @@ impl OAuth2Microsoft { &self.application_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get tenant @@ -77,6 +100,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.application_id(); let _ = _model.application_secret(); + let _ = _model.prompt(); let _ = _model.tenant(); } diff --git a/src/models/o_auth2_notion.rs b/src/models/o_auth2_notion.rs index c42807b..bb32958 100644 --- a/src/models/o_auth2_notion.rs +++ b/src/models/o_auth2_notion.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Notion { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Notion OAuth2 client ID. #[serde(rename = "oauthClientId")] + #[serde(default = "default_oauth_client_id")] pub oauth_client_id: String, /// Notion OAuth2 client secret. #[serde(rename = "oauthClientSecret")] + #[serde(default = "default_oauth_client_secret")] pub oauth_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth_client_id() -> String { + "".to_string() +} + +fn default_oauth_client_secret() -> String { + "".to_string() +} + impl OAuth2Notion { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_oidc.rs b/src/models/o_auth2_oidc.rs index 010281d..aa2df42 100644 --- a/src/models/o_auth2_oidc.rs +++ b/src/models/o_auth2_oidc.rs @@ -8,33 +8,42 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Oidc { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// OpenID Connect OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// OpenID Connect OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, + /// OpenID Connect prompt values controlling the authentication and consent + /// screens. + #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] + pub prompt: Vec, /// OpenID Connect well-known configuration URL. When set, authorization, /// token, and user info endpoints can be discovered automatically. #[serde(rename = "wellKnownURL")] + #[serde(default = "default_well_known_url")] pub well_known_url: String, /// OpenID Connect authorization endpoint URL. #[serde(rename = "authorizationURL")] + #[serde(default = "default_authorization_url")] pub authorization_url: String, /// OpenID Connect token endpoint URL. #[serde(rename = "tokenURL")] + #[serde(default = "default_token_url")] pub token_url: String, /// OpenID Connect user info endpoint URL. #[serde(rename = "userInfoURL")] + #[serde(default = "default_user_info_url")] pub user_info_url: String, - /// OpenID Connect prompt values controlling the authentication and consent - /// screens. - #[serde(rename = "prompt")] - pub prompt: Vec, /// Maximum authentication age in seconds. When set, the user must have /// authenticated within this many seconds. #[serde(rename = "maxAge")] @@ -42,6 +51,42 @@ pub struct OAuth2Oidc { pub max_age: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_well_known_url() -> String { + "".to_string() +} + +fn default_authorization_url() -> String { + "".to_string() +} + +fn default_token_url() -> String { + "".to_string() +} + +fn default_user_info_url() -> String { + "".to_string() +} + impl OAuth2Oidc { /// Get id pub fn id(&self) -> &String { @@ -63,6 +108,11 @@ impl OAuth2Oidc { &self.client_secret } + /// Get prompt + pub fn prompt(&self) -> &Vec { + &self.prompt + } + /// Get well_known_url pub fn well_known_url(&self) -> &String { &self.well_known_url @@ -83,11 +133,6 @@ impl OAuth2Oidc { &self.user_info_url } - /// Get prompt - pub fn prompt(&self) -> &Vec { - &self.prompt - } - /// Set max_age pub fn set_max_age(mut self, max_age: i64) -> Self { self.max_age = Some(max_age); @@ -111,11 +156,11 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.well_known_url(); let _ = _model.authorization_url(); let _ = _model.token_url(); let _ = _model.user_info_url(); - let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_okta.rs b/src/models/o_auth2_okta.rs index e8fdf00..be8da90 100644 --- a/src/models/o_auth2_okta.rs +++ b/src/models/o_auth2_okta.rs @@ -8,28 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Okta { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Okta OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Okta OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Okta OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, /// Okta OAuth2 domain. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Okta OAuth2 authorization server ID. #[serde(rename = "authorizationServerId")] + #[serde(default = "default_authorization_server_id")] pub authorization_server_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_authorization_server_id() -> String { + "".to_string() +} + impl OAuth2Okta { /// Get id pub fn id(&self) -> &String { @@ -51,15 +85,9 @@ impl OAuth2Okta { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } /// Get domain @@ -84,6 +112,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); let _ = _model.domain(); let _ = _model.authorization_server_id(); } diff --git a/src/models/o_auth2_paypal.rs b/src/models/o_auth2_paypal.rs index 41539e5..50ff622 100644 --- a/src/models/o_auth2_paypal.rs +++ b/src/models/o_auth2_paypal.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Paypal { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// PayPal OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// PayPal OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2Paypal { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_podio.rs b/src/models/o_auth2_podio.rs index 87bb74a..cd87360 100644 --- a/src/models/o_auth2_podio.rs +++ b/src/models/o_auth2_podio.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Podio { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Podio OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Podio OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Podio { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_provider_list.rs b/src/models/o_auth2_provider_list.rs index a3354d1..510881c 100644 --- a/src/models/o_auth2_provider_list.rs +++ b/src/models/o_auth2_provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2ProviderList { /// Total number of OAuth2 providers in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of OAuth2 providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl OAuth2ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/o_auth2_resend.rs b/src/models/o_auth2_resend.rs index 1658315..773278e 100644 --- a/src/models/o_auth2_resend.rs +++ b/src/models/o_auth2_resend.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Resend { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Resend OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Resend OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Resend { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_salesforce.rs b/src/models/o_auth2_salesforce.rs index 4565047..addaba3 100644 --- a/src/models/o_auth2_salesforce.rs +++ b/src/models/o_auth2_salesforce.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Salesforce { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Salesforce OAuth2 consumer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// Salesforce OAuth2 consumer secret. #[serde(rename = "customerSecret")] + #[serde(default = "default_customer_secret")] pub customer_secret: String, /// Salesforce OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_customer_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Salesforce { @@ -45,15 +69,9 @@ impl OAuth2Salesforce { &self.customer_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.customer_key(); let _ = _model.customer_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_slack.rs b/src/models/o_auth2_slack.rs index 3045596..1563a50 100644 --- a/src/models/o_auth2_slack.rs +++ b/src/models/o_auth2_slack.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Slack { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Slack OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Slack OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Slack { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_spotify.rs b/src/models/o_auth2_spotify.rs index 00572b9..00d8ad3 100644 --- a/src/models/o_auth2_spotify.rs +++ b/src/models/o_auth2_spotify.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Spotify { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Spotify OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Spotify OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Spotify { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_stripe.rs b/src/models/o_auth2_stripe.rs index 5b1565d..8c7a9c0 100644 --- a/src/models/o_auth2_stripe.rs +++ b/src/models/o_auth2_stripe.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Stripe { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Stripe OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Stripe OAuth2 API secret key. #[serde(rename = "apiSecretKey")] + #[serde(default = "default_api_secret_key")] pub api_secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_api_secret_key() -> String { + "".to_string() +} + impl OAuth2Stripe { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_tradeshift.rs b/src/models/o_auth2_tradeshift.rs index ba79a82..70533ca 100644 --- a/src/models/o_auth2_tradeshift.rs +++ b/src/models/o_auth2_tradeshift.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Tradeshift { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Tradeshift OAuth2 client ID. #[serde(rename = "oauth2ClientId")] + #[serde(default = "default_oauth2_client_id")] pub oauth2_client_id: String, /// Tradeshift OAuth2 client secret. #[serde(rename = "oauth2ClientSecret")] + #[serde(default = "default_oauth2_client_secret")] pub oauth2_client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_oauth2_client_id() -> String { + "".to_string() +} + +fn default_oauth2_client_secret() -> String { + "".to_string() +} + impl OAuth2Tradeshift { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_twitch.rs b/src/models/o_auth2_twitch.rs index e0550f7..d3f246a 100644 --- a/src/models/o_auth2_twitch.rs +++ b/src/models/o_auth2_twitch.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Twitch { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Twitch OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Twitch OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Twitch { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_word_press.rs b/src/models/o_auth2_word_press.rs index a340ebc..52fb61b 100644 --- a/src/models/o_auth2_word_press.rs +++ b/src/models/o_auth2_word_press.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2WordPress { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// WordPress OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// WordPress OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2WordPress { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_x.rs b/src/models/o_auth2_x.rs index c3c4f83..8161a8e 100644 --- a/src/models/o_auth2_x.rs +++ b/src/models/o_auth2_x.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2X { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// X OAuth2 customer key. #[serde(rename = "customerKey")] + #[serde(default = "default_customer_key")] pub customer_key: String, /// X OAuth2 secret key. #[serde(rename = "secretKey")] + #[serde(default = "default_secret_key")] pub secret_key: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_customer_key() -> String { + "".to_string() +} + +fn default_secret_key() -> String { + "".to_string() +} + impl OAuth2X { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yahoo.rs b/src/models/o_auth2_yahoo.rs index 18c69b1..d69e55e 100644 --- a/src/models/o_auth2_yahoo.rs +++ b/src/models/o_auth2_yahoo.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yahoo { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yahoo OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yahoo OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yahoo { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_yandex.rs b/src/models/o_auth2_yandex.rs index 9db7bc6..d7e59dd 100644 --- a/src/models/o_auth2_yandex.rs +++ b/src/models/o_auth2_yandex.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Yandex { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Yandex OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Yandex OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Yandex { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/o_auth2_zoho.rs b/src/models/o_auth2_zoho.rs index 58cef47..8477a96 100644 --- a/src/models/o_auth2_zoho.rs +++ b/src/models/o_auth2_zoho.rs @@ -8,20 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoho { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoho OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoho OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, /// Zoho OAuth2 prompt values. #[serde(rename = "prompt")] - #[serde(skip_serializing_if = "Option::is_none")] - pub prompt: Option>, + #[serde(default = "default_prompt")] + pub prompt: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + +fn default_prompt() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl OAuth2Zoho { @@ -45,15 +69,9 @@ impl OAuth2Zoho { &self.client_secret } - /// Set prompt - pub fn set_prompt(mut self, prompt: Vec) -> Self { - self.prompt = Some(prompt); - self - } - /// Get prompt - pub fn prompt(&self) -> Option<&Vec> { - self.prompt.as_ref() + pub fn prompt(&self) -> &Vec { + &self.prompt } } @@ -68,6 +86,7 @@ mod tests { let _ = _model.enabled(); let _ = _model.client_id(); let _ = _model.client_secret(); + let _ = _model.prompt(); } #[test] diff --git a/src/models/o_auth2_zoom.rs b/src/models/o_auth2_zoom.rs index e0047c3..4c44b8d 100644 --- a/src/models/o_auth2_zoom.rs +++ b/src/models/o_auth2_zoom.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct OAuth2Zoom { /// OAuth2 provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// OAuth2 provider is active and can be used to create sessions. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Zoom OAuth2 client ID. #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] pub client_id: String, /// Zoom OAuth2 client secret. #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] pub client_secret: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_client_id() -> String { + "".to_string() +} + +fn default_client_secret() -> String { + "".to_string() +} + impl OAuth2Zoom { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_approve.rs b/src/models/oauth2_approve.rs index a946f11..ac5ce43 100644 --- a/src/models/oauth2_approve.rs +++ b/src/models/oauth2_approve.rs @@ -10,9 +10,14 @@ pub struct Oauth2Approve { /// carrying the authorization `code` and/or `id_token` along with the original /// `state`. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Approve { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_authorize.rs b/src/models/oauth2_authorize.rs index 5063ed7..89f1f92 100644 --- a/src/models/oauth2_authorize.rs +++ b/src/models/oauth2_authorize.rs @@ -10,13 +10,23 @@ pub struct Oauth2Authorize { /// the approve or reject endpoint. Empty when a redirect URL is returned /// instead. #[serde(rename = "grantId")] + #[serde(default = "default_grant_id")] pub grant_id: String, /// URL the end user should be redirected to when the flow can complete without /// consent. Empty when consent is still required. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_grant_id() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Authorize { /// Get grant_id pub fn grant_id(&self) -> &String { diff --git a/src/models/oauth2_consent.rs b/src/models/oauth2_consent.rs index 995d15b..a6e4b9e 100644 --- a/src/models/oauth2_consent.rs +++ b/src/models/oauth2_consent.rs @@ -8,40 +8,90 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Consent { /// Consent ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Consent creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Consent update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the consent belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the consent was given to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the consent was given to. /// Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes the user consented to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators the user consented to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details the user consented to, as a JSON string. Each entry /// has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Consent expiration time in ISO 8601 format. Empty when the consent has no /// token-bound expiry yet. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Consent { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_list.rs b/src/models/oauth2_consent_list.rs index 3982df2..b019afe 100644 --- a/src/models/oauth2_consent_list.rs +++ b/src/models/oauth2_consent_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentList { /// Total number of consents that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of consents. #[serde(rename = "consents")] + #[serde(default = "default_consents")] pub consents: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_consents() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_consent_token.rs b/src/models/oauth2_consent_token.rs index 4d2f43f..776ba73 100644 --- a/src/models/oauth2_consent_token.rs +++ b/src/models/oauth2_consent_token.rs @@ -8,44 +8,99 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentToken { /// Token family ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Token update date in ISO 8601 format. Refreshing the token family updates /// this. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the consent the token family was issued under. #[serde(rename = "consentId")] + #[serde(default = "default_consent_id")] pub consent_id: String, /// ID of the user the token family belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the registered app the token family was issued to. Empty for URL-form /// (CIMD) clients. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Client ID metadata document URL of the client the token family was issued /// to. Empty for registered apps. #[serde(rename = "cimdUrl")] + #[serde(default = "default_cimd_url")] pub cimd_url: String, /// OAuth2 scopes granted on the token family. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// RFC 8707 resource indicators granted on the token family. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Authorization details granted on the token family, as a JSON string. Each /// entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// Expiration time of the current access token of this family in ISO 8601 /// format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_consent_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_cimd_url() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2ConsentToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_consent_token_list.rs b/src/models/oauth2_consent_token_list.rs index 9f5f5ad..906b8e2 100644 --- a/src/models/oauth2_consent_token_list.rs +++ b/src/models/oauth2_consent_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ConsentTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ConsentTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_device_authorization.rs b/src/models/oauth2_device_authorization.rs index 80feee2..f0bef4d 100644 --- a/src/models/oauth2_device_authorization.rs +++ b/src/models/oauth2_device_authorization.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2DeviceAuthorization { /// Device verification code used by the client to poll the token endpoint. #[serde(rename = "device_code")] + #[serde(default = "default_device_code")] pub device_code: String, /// Short code the end user enters on the verification page. #[serde(rename = "user_code")] + #[serde(default = "default_user_code")] pub user_code: String, /// URL where the end user enters the user code. #[serde(rename = "verification_uri")] + #[serde(default = "default_verification_uri")] pub verification_uri: String, /// Verification URL with the user code prefilled as a query parameter. #[serde(rename = "verification_uri_complete")] + #[serde(default = "default_verification_uri_complete")] pub verification_uri_complete: String, /// Lifetime of the device code and user code in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// Minimum polling interval for the token endpoint in seconds. #[serde(rename = "interval")] + #[serde(default = "default_interval")] pub interval: i64, } +fn default_device_code() -> String { + "".to_string() +} + +fn default_user_code() -> String { + "".to_string() +} + +fn default_verification_uri() -> String { + "".to_string() +} + +fn default_verification_uri_complete() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_interval() -> i64 { + 0 +} + impl Oauth2DeviceAuthorization { /// Get device_code pub fn device_code(&self) -> &String { diff --git a/src/models/oauth2_grant.rs b/src/models/oauth2_grant.rs index 16d716d..b6e37b0 100644 --- a/src/models/oauth2_grant.rs +++ b/src/models/oauth2_grant.rs @@ -8,45 +8,105 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Grant { /// Grant ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Grant creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Grant update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the user the grant belongs to. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// ID of the OAuth2 client (app) the grant was requested for. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Requested OAuth2 scopes the user is being asked to consent to. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Requested RFC 8707 resource indicators the user is being asked to consent /// to. #[serde(rename = "resources")] + #[serde(default = "default_resources")] pub resources: Vec, /// Requested authorization_details the user is being asked to consent to, as a /// JSON string. Each entry has a `type` plus project-defined fields. #[serde(rename = "authorizationDetails")] + #[serde(default = "default_authorization_details")] pub authorization_details: String, /// OIDC prompt directive the consent screen should honor. Space-separated list /// of: login, consent, select_account. #[serde(rename = "prompt")] + #[serde(default = "default_prompt")] pub prompt: String, /// Redirect URI the user will be sent to after the flow completes. #[serde(rename = "redirectUri")] + #[serde(default = "default_redirect_uri")] pub redirect_uri: String, /// Unix timestamp of when the user last authenticated. #[serde(rename = "authTime")] + #[serde(default = "default_auth_time")] pub auth_time: i64, /// Grant expiration time in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_resources() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_authorization_details() -> String { + "[]".to_string() +} + +fn default_prompt() -> String { + "".to_string() +} + +fn default_redirect_uri() -> String { + "".to_string() +} + +fn default_auth_time() -> i64 { + 0 +} + +fn default_expire() -> String { + "".to_string() +} + impl Oauth2Grant { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization.rs b/src/models/oauth2_organization.rs index b2c20fc..ff1bf2b 100644 --- a/src/models/oauth2_organization.rs +++ b/src/models/oauth2_organization.rs @@ -8,9 +8,14 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Organization { /// Organization ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, } +fn default_id() -> String { + "".to_string() +} + impl Oauth2Organization { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_organization_list.rs b/src/models/oauth2_organization_list.rs index 1309964..0188ebd 100644 --- a/src/models/oauth2_organization_list.rs +++ b/src/models/oauth2_organization_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2OrganizationList { /// Total number of organizations that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of organizations. #[serde(rename = "organizations")] + #[serde(default = "default_organizations")] pub organizations: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_organizations() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2OrganizationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_par.rs b/src/models/oauth2_par.rs index f1d779e..09e366f 100644 --- a/src/models/oauth2_par.rs +++ b/src/models/oauth2_par.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2PAR { /// Authorization request handle to pass to the authorize endpoint. #[serde(rename = "request_uri")] + #[serde(default = "default_request_uri")] pub request_uri: String, /// Lifetime of the authorization request handle in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, } +fn default_request_uri() -> String { + "".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + impl Oauth2PAR { /// Get request_uri pub fn request_uri(&self) -> &String { diff --git a/src/models/oauth2_project.rs b/src/models/oauth2_project.rs index 5af4e85..78ea717 100644 --- a/src/models/oauth2_project.rs +++ b/src/models/oauth2_project.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Region ID the project is deployed in. #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, /// API endpoint of the region the project is deployed in. Empty when the /// region has no public hostname configured. #[serde(rename = "endpoint")] + #[serde(default = "default_endpoint")] pub endpoint: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "".to_string() +} + +fn default_endpoint() -> String { + "".to_string() +} + impl Oauth2Project { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/oauth2_project_list.rs b/src/models/oauth2_project_list.rs index 2e849fb..3e8b16c 100644 --- a/src/models/oauth2_project_list.rs +++ b/src/models/oauth2_project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Oauth2ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/oauth2_reject.rs b/src/models/oauth2_reject.rs index 5daab49..7051bb4 100644 --- a/src/models/oauth2_reject.rs +++ b/src/models/oauth2_reject.rs @@ -9,9 +9,14 @@ pub struct Oauth2Reject { /// URL the end user should be redirected to after the grant is rejected, /// carrying an `access_denied` error. #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, } +fn default_redirect_url() -> String { + "".to_string() +} + impl Oauth2Reject { /// Get redirect_url pub fn redirect_url(&self) -> &String { diff --git a/src/models/oauth2_token.rs b/src/models/oauth2_token.rs index 37b8552..9c647fb 100644 --- a/src/models/oauth2_token.rs +++ b/src/models/oauth2_token.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Oauth2Token { /// OAuth2 access token. #[serde(rename = "access_token")] + #[serde(default = "default_access_token")] pub access_token: String, /// OAuth2 token type. #[serde(rename = "token_type")] + #[serde(default = "default_token_type")] pub token_type: String, /// Access token lifetime in seconds. #[serde(rename = "expires_in")] + #[serde(default = "default_expires_in")] pub expires_in: i64, /// OAuth2 refresh token. #[serde(rename = "refresh_token")] + #[serde(default = "default_refresh_token")] pub refresh_token: String, /// Space-separated scopes granted to the access token. #[serde(rename = "scope")] + #[serde(default = "default_scope")] pub scope: String, /// Granted RFC 9396 authorization details as a JSON string. #[serde(rename = "authorization_details")] @@ -31,6 +36,26 @@ pub struct Oauth2Token { pub id_token: Option, } +fn default_access_token() -> String { + "".to_string() +} + +fn default_token_type() -> String { + "Bearer".to_string() +} + +fn default_expires_in() -> i64 { + 0 +} + +fn default_refresh_token() -> String { + "".to_string() +} + +fn default_scope() -> String { + "".to_string() +} + impl Oauth2Token { /// Get access_token pub fn access_token(&self) -> &String { diff --git a/src/models/organization.rs b/src/models/organization.rs index f7ec61d..82eeded 100644 --- a/src/models/organization.rs +++ b/src/models/organization.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Organization { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] @@ -30,44 +35,55 @@ pub struct Organization { pub billing_budget: Option, /// Project budget limit #[serde(rename = "budgetAlerts")] + #[serde(default = "default_budget_alerts")] pub budget_alerts: Vec, /// Organization's billing plan ID. #[serde(rename = "billingPlan")] + #[serde(default = "default_billing_plan")] pub billing_plan: String, /// Organization's billing plan ID. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, /// Organization's billing plan. #[serde(rename = "billingPlanDetails")] pub billing_plan_details: crate::models::BillingPlan, /// Billing email set for the organization. #[serde(rename = "billingEmail")] + #[serde(default = "default_billing_email")] pub billing_email: String, /// Billing cycle start date. #[serde(rename = "billingStartDate")] - pub billing_start_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_start_date: Option, /// Current invoice cycle start date. #[serde(rename = "billingCurrentInvoiceDate")] - pub billing_current_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_current_invoice_date: Option, /// Next invoice cycle start date. #[serde(rename = "billingNextInvoiceDate")] - pub billing_next_invoice_date: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_next_invoice_date: Option, /// Start date of trial. #[serde(rename = "billingTrialStartDate")] #[serde(skip_serializing_if = "Option::is_none")] pub billing_trial_start_date: Option, /// Number of trial days. #[serde(rename = "billingTrialDays")] - pub billing_trial_days: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_trial_days: Option, /// Current active aggregation id. #[serde(rename = "billingAggregationId")] - pub billing_aggregation_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_aggregation_id: Option, /// Current active aggregation id. #[serde(rename = "billingInvoiceId")] - pub billing_invoice_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_invoice_id: Option, /// Default payment method. #[serde(rename = "paymentMethodId")] - pub payment_method_id: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_id: Option, /// Default payment method. #[serde(rename = "billingAddressId")] #[serde(skip_serializing_if = "Option::is_none")] @@ -78,6 +94,7 @@ pub struct Organization { pub backup_payment_method_id: Option, /// Team status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Remarks on team status. #[serde(rename = "remarks")] @@ -117,15 +134,70 @@ pub struct Organization { pub billing_tax_id: Option, /// Marked for deletion #[serde(rename = "markedForDeletion")] + #[serde(default = "default_marked_for_deletion")] pub marked_for_deletion: bool, /// Product with which the organization is associated (appwrite or imagine) #[serde(rename = "platform")] + #[serde(default = "default_platform")] pub platform: String, /// Selected projects #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + +fn default_budget_alerts() -> Vec { + serde_json::from_value(serde_json::json!([75])).unwrap() +} + +fn default_billing_plan() -> String { + "tier-0".to_string() +} + +fn default_billing_plan_id() -> String { + "tier-0".to_string() +} + +fn default_billing_email() -> String { + "".to_string() +} + +fn default_status() -> String { + "draft".to_string() +} + +fn default_marked_for_deletion() -> bool { + false +} + +fn default_platform() -> String { + "appwrite".to_string() +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Organization { /// Get id pub fn id(&self) -> &String { @@ -193,19 +265,40 @@ impl Organization { &self.billing_email } + /// Set billing_start_date + pub fn set_billing_start_date(mut self, billing_start_date: String) -> Self { + self.billing_start_date = Some(billing_start_date); + self + } + /// Get billing_start_date - pub fn billing_start_date(&self) -> &String { - &self.billing_start_date + pub fn billing_start_date(&self) -> Option<&String> { + self.billing_start_date.as_ref() + } + + /// Set billing_current_invoice_date + pub fn set_billing_current_invoice_date( + mut self, + billing_current_invoice_date: String, + ) -> Self { + self.billing_current_invoice_date = Some(billing_current_invoice_date); + self } /// Get billing_current_invoice_date - pub fn billing_current_invoice_date(&self) -> &String { - &self.billing_current_invoice_date + pub fn billing_current_invoice_date(&self) -> Option<&String> { + self.billing_current_invoice_date.as_ref() + } + + /// Set billing_next_invoice_date + pub fn set_billing_next_invoice_date(mut self, billing_next_invoice_date: String) -> Self { + self.billing_next_invoice_date = Some(billing_next_invoice_date); + self } /// Get billing_next_invoice_date - pub fn billing_next_invoice_date(&self) -> &String { - &self.billing_next_invoice_date + pub fn billing_next_invoice_date(&self) -> Option<&String> { + self.billing_next_invoice_date.as_ref() } /// Set billing_trial_start_date @@ -219,24 +312,48 @@ impl Organization { self.billing_trial_start_date.as_ref() } + /// Set billing_trial_days + pub fn set_billing_trial_days(mut self, billing_trial_days: i64) -> Self { + self.billing_trial_days = Some(billing_trial_days); + self + } + /// Get billing_trial_days - pub fn billing_trial_days(&self) -> &i64 { - &self.billing_trial_days + pub fn billing_trial_days(&self) -> Option<&i64> { + self.billing_trial_days.as_ref() + } + + /// Set billing_aggregation_id + pub fn set_billing_aggregation_id(mut self, billing_aggregation_id: String) -> Self { + self.billing_aggregation_id = Some(billing_aggregation_id); + self } /// Get billing_aggregation_id - pub fn billing_aggregation_id(&self) -> &String { - &self.billing_aggregation_id + pub fn billing_aggregation_id(&self) -> Option<&String> { + self.billing_aggregation_id.as_ref() + } + + /// Set billing_invoice_id + pub fn set_billing_invoice_id(mut self, billing_invoice_id: String) -> Self { + self.billing_invoice_id = Some(billing_invoice_id); + self } /// Get billing_invoice_id - pub fn billing_invoice_id(&self) -> &String { - &self.billing_invoice_id + pub fn billing_invoice_id(&self) -> Option<&String> { + self.billing_invoice_id.as_ref() + } + + /// Set payment_method_id + pub fn set_payment_method_id(mut self, payment_method_id: String) -> Self { + self.payment_method_id = Some(payment_method_id); + self } /// Get payment_method_id - pub fn payment_method_id(&self) -> &String { - &self.payment_method_id + pub fn payment_method_id(&self) -> Option<&String> { + self.payment_method_id.as_ref() } /// Set billing_address_id @@ -402,13 +519,6 @@ mod tests { let _ = _model.billing_plan_id(); let _ = _model.billing_plan_details(); let _ = _model.billing_email(); - let _ = _model.billing_start_date(); - let _ = _model.billing_current_invoice_date(); - let _ = _model.billing_next_invoice_date(); - let _ = _model.billing_trial_days(); - let _ = _model.billing_aggregation_id(); - let _ = _model.billing_invoice_id(); - let _ = _model.payment_method_id(); let _ = _model.status(); let _ = _model.marked_for_deletion(); let _ = _model.platform(); diff --git a/src/models/passkey.rs b/src/models/passkey.rs index 0685af4..9f9afb4 100644 --- a/src/models/passkey.rs +++ b/src/models/passkey.rs @@ -8,22 +8,47 @@ use serde::{Deserialize, Serialize}; pub struct Passkey { /// Passkey ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Passkey creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Passkey update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Passkey name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Most recent sign-in with this passkey in ISO 8601 format. Empty until the /// passkey is used to sign in. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl Passkey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_challenge.rs b/src/models/passkey_challenge.rs index 8ecada5..a0cffe5 100644 --- a/src/models/passkey_challenge.rs +++ b/src/models/passkey_challenge.rs @@ -9,23 +9,48 @@ pub struct PasskeyChallenge { /// Challenge ID. When signing in, pass it back with the credential to receive /// a token. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Challenge creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// ID of the passkey being registered. Empty for sign-in challenges. #[serde(rename = "passkeyId")] + #[serde(default = "default_passkey_id")] pub passkey_id: String, /// Challenge expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// WebAuthn options in JSON form. Pass them to /// `PublicKeyCredential.parseCreationOptionsFromJSON()` when registering, or /// `PublicKeyCredential.parseRequestOptionsFromJSON()` when signing in. #[serde(rename = "publicKey")] + #[serde(default = "default_public_key")] pub public_key: serde_json::Value, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_passkey_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_public_key() -> serde_json::Value { + serde_json::json!({}) +} + impl PasskeyChallenge { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/passkey_list.rs b/src/models/passkey_list.rs index 8b9e05e..5f9a82c 100644 --- a/src/models/passkey_list.rs +++ b/src/models/passkey_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PasskeyList { /// Total number of passkeys that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of passkeys. #[serde(rename = "passkeys")] + #[serde(default = "default_passkeys")] pub passkeys: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_passkeys() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PasskeyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/phone.rs b/src/models/phone.rs index 2d6a27c..f06631b 100644 --- a/src/models/phone.rs +++ b/src/models/phone.rs @@ -8,15 +8,30 @@ use serde::{Deserialize, Serialize}; pub struct Phone { /// Phone code. #[serde(rename = "code")] + #[serde(default = "default_code")] pub code: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, } +fn default_code() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + impl Phone { /// Get code pub fn code(&self) -> &String { diff --git a/src/models/phone_list.rs b/src/models/phone_list.rs index 53939ae..b17138c 100644 --- a/src/models/phone_list.rs +++ b/src/models/phone_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PhoneList { /// Total number of phones that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of phones. #[serde(rename = "phones")] + #[serde(default = "default_phones")] pub phones: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_phones() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PhoneList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_android.rs b/src/models/platform_android.rs index 7f35a47..28a4ac1 100644 --- a/src/models/platform_android.rs +++ b/src/models/platform_android.rs @@ -8,27 +8,56 @@ use serde::{Deserialize, Serialize}; pub struct PlatformAndroid { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Android application ID. #[serde(rename = "applicationId")] + #[serde(default = "default_application_id")] pub application_id: String, /// SHA-256 fingerprints of the certificates the app is signed with. Passkeys /// created in the app are accepted when its signature matches one. #[serde(rename = "fingerprints")] - #[serde(skip_serializing_if = "Option::is_none")] - pub fingerprints: Option>, + #[serde(default = "default_fingerprints")] + pub fingerprints: Vec, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_application_id() -> String { + "".to_string() +} + +fn default_fingerprints() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() } impl PlatformAndroid { @@ -62,15 +91,9 @@ impl PlatformAndroid { &self.application_id } - /// Set fingerprints - pub fn set_fingerprints(mut self, fingerprints: Vec) -> Self { - self.fingerprints = Some(fingerprints); - self - } - /// Get fingerprints - pub fn fingerprints(&self) -> Option<&Vec> { - self.fingerprints.as_ref() + pub fn fingerprints(&self) -> &Vec { + &self.fingerprints } } @@ -87,6 +110,7 @@ mod tests { let _ = _model.name(); let _ = _model.r#type(); let _ = _model.application_id(); + let _ = _model.fingerprints(); } #[test] diff --git a/src/models/platform_apple.rs b/src/models/platform_apple.rs index c157274..fd57555 100644 --- a/src/models/platform_apple.rs +++ b/src/models/platform_apple.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformApple { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Apple bundle identifier. #[serde(rename = "bundleIdentifier")] + #[serde(default = "default_bundle_identifier")] pub bundle_identifier: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_bundle_identifier() -> String { + "".to_string() +} + impl PlatformApple { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_linux.rs b/src/models/platform_linux.rs index d305b51..db7b998 100644 --- a/src/models/platform_linux.rs +++ b/src/models/platform_linux.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformLinux { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Linux package name. #[serde(rename = "packageName")] + #[serde(default = "default_package_name")] pub package_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_name() -> String { + "".to_string() +} + impl PlatformLinux { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_list.rs b/src/models/platform_list.rs index 523fc50..5caaee7 100644 --- a/src/models/platform_list.rs +++ b/src/models/platform_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PlatformList { /// Total number of platforms in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of platforms. #[serde(rename = "platforms")] + #[serde(default = "default_platforms")] pub platforms: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_platforms() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PlatformList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/platform_web.rs b/src/models/platform_web.rs index 5daea92..a35b4c5 100644 --- a/src/models/platform_web.rs +++ b/src/models/platform_web.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWeb { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Web app hostname. Empty string for other platforms. #[serde(rename = "hostname")] + #[serde(default = "default_hostname")] pub hostname: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_hostname() -> String { + "".to_string() +} + impl PlatformWeb { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/platform_windows.rs b/src/models/platform_windows.rs index da5c08f..52d9c7a 100644 --- a/src/models/platform_windows.rs +++ b/src/models/platform_windows.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct PlatformWindows { /// Platform ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Platform creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Platform update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Platform name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Platform type. Possible values are: windows, apple, android, linux, web. #[serde(rename = "type")] pub r#type: crate::enums::PlatformType, /// Windows package identifier name. #[serde(rename = "packageIdentifierName")] + #[serde(default = "default_package_identifier_name")] pub package_identifier_name: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_package_identifier_name() -> String { + "".to_string() +} + impl PlatformWindows { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_aliased_email.rs b/src/models/policy_deny_aliased_email.rs index c7327b0..bca4bde 100644 --- a/src/models/policy_deny_aliased_email.rs +++ b/src/models/policy_deny_aliased_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyAliasedEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny aliased email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyAliasedEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_corporate_email.rs b/src/models/policy_deny_corporate_email.rs index 8b271b9..b90e444 100644 --- a/src/models/policy_deny_corporate_email.rs +++ b/src/models/policy_deny_corporate_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyCorporateEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny non-corporate email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyCorporateEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_disposable_email.rs b/src/models/policy_deny_disposable_email.rs index 029a4fe..3cfb4ec 100644 --- a/src/models/policy_deny_disposable_email.rs +++ b/src/models/policy_deny_disposable_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyDisposableEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny disposable email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyDisposableEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_deny_free_email.rs b/src/models/policy_deny_free_email.rs index 6038f66..5c1b61d 100644 --- a/src/models/policy_deny_free_email.rs +++ b/src/models/policy_deny_free_email.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyDenyFreeEmail { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether the deny free email policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyDenyFreeEmail { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_list.rs b/src/models/policy_list.rs index 559b319..cec5f0b 100644 --- a/src/models/policy_list.rs +++ b/src/models/policy_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyList { /// Total number of policies in the given project. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of policies. #[serde(rename = "policies")] + #[serde(default = "default_policies")] pub policies: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_policies() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/policy_membership_privacy.rs b/src/models/policy_membership_privacy.rs index 8b17314..c42cc90 100644 --- a/src/models/policy_membership_privacy.rs +++ b/src/models/policy_membership_privacy.rs @@ -8,27 +8,62 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMembershipPrivacy { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether user ID is visible in memberships. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: bool, /// Whether user email is visible in memberships. #[serde(rename = "userEmail")] + #[serde(default = "default_user_email")] pub user_email: bool, /// Whether user phone is visible in memberships. #[serde(rename = "userPhone")] + #[serde(default = "default_user_phone")] pub user_phone: bool, /// Whether user name is visible in memberships. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: bool, /// Whether user MFA status is visible in memberships. #[serde(rename = "userMFA")] + #[serde(default = "default_user_mfa")] pub user_mfa: bool, /// Whether user last access time is visible in memberships. #[serde(rename = "userAccessedAt")] + #[serde(default = "default_user_accessed_at")] pub user_accessed_at: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_user_id() -> bool { + false +} + +fn default_user_email() -> bool { + false +} + +fn default_user_phone() -> bool { + false +} + +fn default_user_name() -> bool { + false +} + +fn default_user_mfa() -> bool { + false +} + +fn default_user_accessed_at() -> bool { + false +} + impl PolicyMembershipPrivacy { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_mfa_factors.rs b/src/models/policy_mfa_factors.rs index a6634b6..5d6a1f3 100644 --- a/src/models/policy_mfa_factors.rs +++ b/src/models/policy_mfa_factors.rs @@ -8,21 +8,46 @@ use serde::{Deserialize, Serialize}; pub struct PolicyMfaFactors { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether TOTP can be used to complete an MFA challenge. #[serde(rename = "totp")] + #[serde(default = "default_totp")] pub totp: bool, /// Whether email can be used to complete an MFA challenge. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: bool, /// Whether phone (SMS) can be used to complete an MFA challenge. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: bool, /// Whether the custom factor can be used to complete an MFA challenge. #[serde(rename = "custom")] + #[serde(default = "default_custom")] pub custom: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_totp() -> bool { + true +} + +fn default_email() -> bool { + true +} + +fn default_phone() -> bool { + true +} + +fn default_custom() -> bool { + false +} + impl PolicyMfaFactors { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_passkey.rs b/src/models/policy_passkey.rs index 3306d5e..e556cbc 100644 --- a/src/models/policy_passkey.rs +++ b/src/models/policy_passkey.rs @@ -8,16 +8,31 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasskey { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Relying party ID passkeys are bound to. Empty until configured. #[serde(rename = "rpId")] + #[serde(default = "default_rp_id")] pub rp_id: String, /// Web origins passkeys work on, from the project's platforms on the relying /// party ID and a localhost web platform. Read-only. #[serde(rename = "origins")] + #[serde(default = "default_origins")] pub origins: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_rp_id() -> String { + "".to_string() +} + +fn default_origins() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PolicyPasskey { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_dictionary.rs b/src/models/policy_password_dictionary.rs index e14d27b..2d9857d 100644 --- a/src/models/policy_password_dictionary.rs +++ b/src/models/policy_password_dictionary.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordDictionary { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password dictionary policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordDictionary { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_history.rs b/src/models/policy_password_history.rs index 6f00db0..e356b25 100644 --- a/src/models/policy_password_history.rs +++ b/src/models/policy_password_history.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordHistory { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Password history length. A value of 0 means the policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyPasswordHistory { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_personal_data.rs b/src/models/policy_password_personal_data.rs index 6fee0df..9b19000 100644 --- a/src/models/policy_password_personal_data.rs +++ b/src/models/policy_password_personal_data.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordPersonalData { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether password personal data policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicyPasswordPersonalData { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_password_strength.rs b/src/models/policy_password_strength.rs index fa3b56a..08ff7bb 100644 --- a/src/models/policy_password_strength.rs +++ b/src/models/policy_password_strength.rs @@ -8,24 +8,54 @@ use serde::{Deserialize, Serialize}; pub struct PolicyPasswordStrength { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Minimum password length required for user passwords. #[serde(rename = "min")] + #[serde(default = "default_min")] pub min: i64, /// Whether passwords must include at least one uppercase letter. #[serde(rename = "uppercase")] + #[serde(default = "default_uppercase")] pub uppercase: bool, /// Whether passwords must include at least one lowercase letter. #[serde(rename = "lowercase")] + #[serde(default = "default_lowercase")] pub lowercase: bool, /// Whether passwords must include at least one number. #[serde(rename = "number")] + #[serde(default = "default_number")] pub number: bool, /// Whether passwords must include at least one symbol. #[serde(rename = "symbols")] + #[serde(default = "default_symbols")] pub symbols: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_min() -> i64 { + 8 +} + +fn default_uppercase() -> bool { + false +} + +fn default_lowercase() -> bool { + false +} + +fn default_number() -> bool { + false +} + +fn default_symbols() -> bool { + false +} + impl PolicyPasswordStrength { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_alert.rs b/src/models/policy_session_alert.rs index 3689003..84ebba2 100644 --- a/src/models/policy_session_alert.rs +++ b/src/models/policy_session_alert.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionAlert { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session alert policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + impl PolicySessionAlert { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_duration.rs b/src/models/policy_session_duration.rs index 4cf1a79..93e96dc 100644 --- a/src/models/policy_session_duration.rs +++ b/src/models/policy_session_duration.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionDuration { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session duration in seconds. #[serde(rename = "duration")] + #[serde(default = "default_duration")] pub duration: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_duration() -> i64 { + 31536000 +} + impl PolicySessionDuration { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_invalidation.rs b/src/models/policy_session_invalidation.rs index 07846c9..f63d898 100644 --- a/src/models/policy_session_invalidation.rs +++ b/src/models/policy_session_invalidation.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionInvalidation { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Whether session invalidation policy is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + impl PolicySessionInvalidation { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_session_limit.rs b/src/models/policy_session_limit.rs index 86f066f..c6b02b8 100644 --- a/src/models/policy_session_limit.rs +++ b/src/models/policy_session_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicySessionLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of sessions allowed per user. A value of 0 means the policy /// is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicySessionLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/policy_user_limit.rs b/src/models/policy_user_limit.rs index 4515afd..84b0359 100644 --- a/src/models/policy_user_limit.rs +++ b/src/models/policy_user_limit.rs @@ -8,13 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct PolicyUserLimit { /// Policy ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Maximum number of users allowed in the project. A value of 0 means the /// policy is disabled. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl PolicyUserLimit { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/postgres_extension.rs b/src/models/postgres_extension.rs index 6fa2b95..8e2cb31 100644 --- a/src/models/postgres_extension.rs +++ b/src/models/postgres_extension.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct PostgresExtension { /// Extension key used with CREATE EXTENSION. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Human-readable extension name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Short description of what the extension provides. #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Category the extension belongs to. #[serde(rename = "category")] + #[serde(default = "default_category")] pub category: String, } +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_category() -> String { + "".to_string() +} + impl PostgresExtension { /// Get key pub fn key(&self) -> &String { diff --git a/src/models/presence.rs b/src/models/presence.rs index 5ed34d4..845310e 100644 --- a/src/models/presence.rs +++ b/src/models/presence.rs @@ -8,19 +8,24 @@ use serde::{Deserialize, Serialize}; pub struct Presence { /// Presence ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Presence creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Presence update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Presence permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Presence status. #[serde(rename = "status")] @@ -28,6 +33,7 @@ pub struct Presence { pub status: Option, /// Presence source. #[serde(rename = "source")] + #[serde(default = "default_source")] pub source: String, /// Presence expiry date in ISO 8601 format. #[serde(rename = "expiresAt")] @@ -39,6 +45,30 @@ pub struct Presence { pub metadata: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_source() -> String { + "".to_string() +} + impl Presence { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/presence_list.rs b/src/models/presence_list.rs index 0257bf7..6a006b2 100644 --- a/src/models/presence_list.rs +++ b/src/models/presence_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct PresenceList { /// Total number of presences that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of presences. #[serde(rename = "presences")] + #[serde(default = "default_presences")] pub presences: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_presences() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl PresenceList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/program.rs b/src/models/program.rs index 588d509..06eedf7 100644 --- a/src/models/program.rs +++ b/src/models/program.rs @@ -8,33 +8,78 @@ use serde::{Deserialize, Serialize}; pub struct Program { /// Program ID #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Program title #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Program description #[serde(rename = "description")] + #[serde(default = "default_description")] pub description: String, /// Program tag for highlighting on console #[serde(rename = "tag")] + #[serde(default = "default_tag")] pub tag: String, /// Program icon for highlighting on console #[serde(rename = "icon")] + #[serde(default = "default_icon")] pub icon: String, /// URL for more information on this program #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Whether this program is active #[serde(rename = "active")] + #[serde(default = "default_active")] pub active: bool, /// Whether this program is external #[serde(rename = "external")] + #[serde(default = "default_external")] pub external: bool, /// Billing plan ID that this is program is associated with. #[serde(rename = "billingPlanId")] + #[serde(default = "default_billing_plan_id")] pub billing_plan_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_tag() -> String { + "".to_string() +} + +fn default_icon() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_active() -> bool { + true +} + +fn default_external() -> bool { + true +} + +fn default_billing_plan_id() -> String { + "".to_string() +} + impl Program { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/project.rs b/src/models/project.rs index 78a7fc7..962b910 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -8,87 +8,110 @@ use serde::{Deserialize, Serialize}; pub struct Project { /// Project ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Project creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Project update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Project name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Project team ID. #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] pub team_id: String, /// Project region #[serde(rename = "region")] + #[serde(default = "default_region")] pub region: String, - /// Deprecated since 1.9.5: List of dev keys. - #[serde(rename = "devKeys")] - pub dev_keys: Vec, /// Status for custom SMTP #[serde(rename = "smtpEnabled")] + #[serde(default = "default_smtp_enabled")] pub smtp_enabled: bool, /// SMTP sender name #[serde(rename = "smtpSenderName")] + #[serde(default = "default_smtp_sender_name")] pub smtp_sender_name: String, /// SMTP sender email #[serde(rename = "smtpSenderEmail")] + #[serde(default = "default_smtp_sender_email")] pub smtp_sender_email: String, /// SMTP reply to name #[serde(rename = "smtpReplyToName")] + #[serde(default = "default_smtp_reply_to_name")] pub smtp_reply_to_name: String, /// SMTP reply to email #[serde(rename = "smtpReplyToEmail")] + #[serde(default = "default_smtp_reply_to_email")] pub smtp_reply_to_email: String, /// SMTP server host name #[serde(rename = "smtpHost")] + #[serde(default = "default_smtp_host")] pub smtp_host: String, /// SMTP server port #[serde(rename = "smtpPort")] + #[serde(default = "default_smtp_port")] pub smtp_port: i64, /// SMTP server username #[serde(rename = "smtpUsername")] + #[serde(default = "default_smtp_username")] pub smtp_username: String, /// SMTP server password. This property is write-only and always returned /// empty. #[serde(rename = "smtpPassword")] + #[serde(default = "default_smtp_password")] pub smtp_password: String, /// SMTP server secure protocol #[serde(rename = "smtpSecure")] + #[serde(default = "default_smtp_secure")] pub smtp_secure: String, /// Number of times the ping was received for this project. #[serde(rename = "pingCount")] + #[serde(default = "default_ping_count")] pub ping_count: i64, /// Last ping datetime in ISO 8601 format. #[serde(rename = "pingedAt")] + #[serde(default = "default_pinged_at")] pub pinged_at: String, /// Labels for the project. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Project status #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Stage progress (completed or skipped) with timestamps and actor types, /// keyed by stage id. #[serde(rename = "onboarding")] + #[serde(default = "default_onboarding")] pub onboarding: serde_json::Value, /// List of auth methods. #[serde(rename = "authMethods")] + #[serde(default = "default_auth_methods")] pub auth_methods: Vec, /// List of services. #[serde(rename = "services")] + #[serde(default = "default_services")] pub services: Vec, /// List of protocols. #[serde(rename = "protocols")] + #[serde(default = "default_protocols")] pub protocols: Vec, /// Project blocks information #[serde(rename = "blocks")] + #[serde(default = "default_blocks")] pub blocks: Vec, /// Last time the project was accessed via console. Used with plan's /// projectInactivityDays to determine if project is paused. #[serde(rename = "consoleAccessedAt")] + #[serde(default = "default_console_accessed_at")] pub console_accessed_at: String, /// Whether WAF enforcement is enabled for the project. #[serde(rename = "wafEnabled")] @@ -192,6 +215,110 @@ pub struct Project { pub o_auth2_server_discovery_url: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_region() -> String { + "fra".to_string() +} + +fn default_smtp_enabled() -> bool { + false +} + +fn default_smtp_sender_name() -> String { + "".to_string() +} + +fn default_smtp_sender_email() -> String { + "".to_string() +} + +fn default_smtp_reply_to_name() -> String { + "".to_string() +} + +fn default_smtp_reply_to_email() -> String { + "".to_string() +} + +fn default_smtp_host() -> String { + "".to_string() +} + +fn default_smtp_port() -> i64 { + 0 +} + +fn default_smtp_username() -> String { + "".to_string() +} + +fn default_smtp_password() -> String { + "".to_string() +} + +fn default_smtp_secure() -> String { + "".to_string() +} + +fn default_ping_count() -> i64 { + 0 +} + +fn default_pinged_at() -> String { + "".to_string() +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_status() -> String { + "active".to_string() +} + +fn default_onboarding() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_auth_methods() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_services() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_protocols() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_blocks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_console_accessed_at() -> String { + "".to_string() +} + impl Project { /// Get id pub fn id(&self) -> &String { @@ -223,11 +350,6 @@ impl Project { &self.region } - /// Get dev_keys - pub fn dev_keys(&self) -> &Vec { - &self.dev_keys - } - /// Get smtp_enabled pub fn smtp_enabled(&self) -> &bool { &self.smtp_enabled @@ -634,7 +756,6 @@ mod tests { let _ = _model.name(); let _ = _model.team_id(); let _ = _model.region(); - let _ = _model.dev_keys(); let _ = _model.smtp_enabled(); let _ = _model.smtp_sender_name(); let _ = _model.smtp_sender_email(); diff --git a/src/models/project_auth_method.rs b/src/models/project_auth_method.rs index e8428f1..37f1ef8 100644 --- a/src/models/project_auth_method.rs +++ b/src/models/project_auth_method.rs @@ -11,9 +11,14 @@ pub struct ProjectAuthMethod { pub id: crate::enums::ProjectAuthMethodId, /// Auth method status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectAuthMethod { /// Get id pub fn id(&self) -> &crate::enums::ProjectAuthMethodId { diff --git a/src/models/project_list.rs b/src/models/project_list.rs index 9bcda60..83f9fdc 100644 --- a/src/models/project_list.rs +++ b/src/models/project_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProjectList { /// Total number of projects that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of projects. #[serde(rename = "projects")] + #[serde(default = "default_projects")] pub projects: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_projects() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProjectList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/project_protocol.rs b/src/models/project_protocol.rs index a8bd9e1..82cf49e 100644 --- a/src/models/project_protocol.rs +++ b/src/models/project_protocol.rs @@ -11,9 +11,14 @@ pub struct ProjectProtocol { pub id: crate::enums::ProjectProtocolId, /// Protocol status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectProtocol { /// Get id pub fn id(&self) -> &crate::enums::ProjectProtocolId { diff --git a/src/models/project_service.rs b/src/models/project_service.rs index 4d94d38..7601ae4 100644 --- a/src/models/project_service.rs +++ b/src/models/project_service.rs @@ -11,9 +11,14 @@ pub struct ProjectService { pub id: crate::enums::ProjectServiceId, /// Service status. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, } +fn default_enabled() -> bool { + true +} + impl ProjectService { /// Get id pub fn id(&self) -> &crate::enums::ProjectServiceId { diff --git a/src/models/provider.rs b/src/models/provider.rs index 6da6a12..0730ec8 100644 --- a/src/models/provider.rs +++ b/src/models/provider.rs @@ -8,27 +8,35 @@ use serde::{Deserialize, Serialize}; pub struct Provider { /// Provider ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Provider creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Provider update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name for the provider instance. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// The name of the provider service. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Is provider enabled? #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Type of provider. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Provider credentials. #[serde(rename = "credentials")] + #[serde(default = "default_credentials")] pub credentials: serde_json::Value, /// Provider options. #[serde(rename = "options")] @@ -36,6 +44,38 @@ pub struct Provider { pub options: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_type() -> String { + "".to_string() +} + +fn default_credentials() -> serde_json::Value { + serde_json::json!({}) +} + impl Provider { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/provider_list.rs b/src/models/provider_list.rs index 3d9c5c9..8d6e077 100644 --- a/src/models/provider_list.rs +++ b/src/models/provider_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProviderList { /// Total number of providers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of providers. #[serde(rename = "providers")] + #[serde(default = "default_providers")] pub providers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_providers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProviderList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/proxy_invalidation.rs b/src/models/proxy_invalidation.rs index eaec944..575f927 100644 --- a/src/models/proxy_invalidation.rs +++ b/src/models/proxy_invalidation.rs @@ -8,19 +8,39 @@ use serde::{Deserialize, Serialize}; pub struct ProxyInvalidation { /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Invalidation type. Possible values are "tag", "path", or "all". #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Invalidated reference. Depending on type this is a cache tag name, a URL /// path, or empty when type is all. #[serde(rename = "reference")] + #[serde(default = "default_reference")] pub reference: String, /// Invalidation status. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, } +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_reference() -> String { + "".to_string() +} + +fn default_status() -> String { + "".to_string() +} + impl ProxyInvalidation { /// Get domain pub fn domain(&self) -> &String { diff --git a/src/models/proxy_rule.rs b/src/models/proxy_rule.rs index 1082f77..98d4390 100644 --- a/src/models/proxy_rule.rs +++ b/src/models/proxy_rule.rs @@ -8,56 +8,128 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRule { /// Rule ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Rule creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Rule update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Domain name. #[serde(rename = "domain")] + #[serde(default = "default_domain")] pub domain: String, /// Action definition for the rule. Possible values are "api", "deployment", or /// "redirect" #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Defines how the rule was created. Possible values are "manual" or /// "deployment" #[serde(rename = "trigger")] + #[serde(default = "default_trigger")] pub trigger: String, /// URL to redirect to. Used if type is "redirect" #[serde(rename = "redirectUrl")] + #[serde(default = "default_redirect_url")] pub redirect_url: String, /// Status code to apply during redirect. Used if type is "redirect" #[serde(rename = "redirectStatusCode")] + #[serde(default = "default_redirect_status_code")] pub redirect_status_code: i64, /// ID of deployment. Used if type is "deployment" #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, - /// Type of deployment. Possible values are "function", "site". Used if rule's - /// type is "deployment". + /// Type of deployment resource: function, site, or dedicatedDatabase. #[serde(rename = "deploymentResourceType")] #[serde(skip_serializing_if = "Option::is_none")] pub deployment_resource_type: Option, /// ID of deployment's resource (site or function ID). Used if type is /// "deployment" #[serde(rename = "deploymentResourceId")] + #[serde(default = "default_deployment_resource_id")] pub deployment_resource_id: String, /// Name of Git branch that updates rule. Used if type is "deployment" #[serde(rename = "deploymentVcsProviderBranch")] + #[serde(default = "default_deployment_vcs_provider_branch")] pub deployment_vcs_provider_branch: String, /// Domain verification status. Possible values are "unverified", "verifying", /// "verified" #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: crate::enums::ProxyRuleStatus, /// Logs from rule verification or certificate generation. Certificate /// generation logs are prioritized if both are available. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Certificate auto-renewal date in ISO 8601 format. #[serde(rename = "renewAt")] pub renew_at: String, + /// Ingress protocol for the rule. + #[serde(rename = "protocol")] + #[serde(default = "default_protocol")] + pub protocol: crate::enums::ProxyRuleProtocol, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_trigger() -> String { + "".to_string() +} + +fn default_redirect_url() -> String { + "".to_string() +} + +fn default_redirect_status_code() -> i64 { + 301 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_resource_id() -> String { + "".to_string() +} + +fn default_deployment_vcs_provider_branch() -> String { + "".to_string() +} + +fn default_status() -> crate::enums::ProxyRuleStatus { + serde_json::from_value(serde_json::json!("unverified")).unwrap() +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_protocol() -> crate::enums::ProxyRuleProtocol { + serde_json::from_value(serde_json::json!("http")).unwrap() } impl ProxyRule { @@ -146,6 +218,11 @@ impl ProxyRule { pub fn renew_at(&self) -> &String { &self.renew_at } + + /// Get protocol + pub fn protocol(&self) -> &crate::enums::ProxyRuleProtocol { + &self.protocol + } } #[cfg(test)] @@ -169,6 +246,7 @@ mod tests { let _ = _model.status(); let _ = _model.logs(); let _ = _model.renew_at(); + let _ = _model.protocol(); } #[test] diff --git a/src/models/proxy_rule_list.rs b/src/models/proxy_rule_list.rs index ddd137d..e6ac600 100644 --- a/src/models/proxy_rule_list.rs +++ b/src/models/proxy_rule_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ProxyRuleList { /// Total number of rules that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rules. #[serde(rename = "rules")] + #[serde(default = "default_rules")] pub rules: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rules() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ProxyRuleList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/report.rs b/src/models/report.rs index 4f43770..f1992ae 100644 --- a/src/models/report.rs +++ b/src/models/report.rs @@ -8,38 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Report { /// Report ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Report creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Report update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// ID of the third-party app that submitted the report. #[serde(rename = "appId")] + #[serde(default = "default_app_id")] pub app_id: String, /// Analyzer that produced this report. e.g. lighthouse, audit, /// databaseAnalyzer. #[serde(rename = "type")] + #[serde(default = "default_type")] pub r#type: String, /// Short, human-readable title for the report. #[serde(rename = "title")] + #[serde(default = "default_title")] pub title: String, /// Markdown summary describing the report. #[serde(rename = "summary")] + #[serde(default = "default_summary")] pub summary: String, /// Plural noun describing what the report analyzes, e.g. databases, sites, /// urls. #[serde(rename = "targetType")] + #[serde(default = "default_target_type")] pub target_type: String, /// Free-form target identifier (URL for lighthouse, resource ID for db). #[serde(rename = "target")] + #[serde(default = "default_target")] pub target: String, /// Categories covered by the report, e.g. performance, accessibility. #[serde(rename = "categories")] + #[serde(default = "default_categories")] pub categories: Vec, /// Insights nested under this report. #[serde(rename = "insights")] + #[serde(default = "default_insights")] pub insights: Vec, /// Time the report was analyzed in ISO 8601 format. #[serde(rename = "analyzedAt")] @@ -47,6 +58,50 @@ pub struct Report { pub analyzed_at: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_app_id() -> String { + "".to_string() +} + +fn default_type() -> String { + "".to_string() +} + +fn default_title() -> String { + "".to_string() +} + +fn default_summary() -> String { + "".to_string() +} + +fn default_target_type() -> String { + "".to_string() +} + +fn default_target() -> String { + "".to_string() +} + +fn default_categories() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_insights() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Report { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/report_list.rs b/src/models/report_list.rs index 81b4995..4c1c5ca 100644 --- a/src/models/report_list.rs +++ b/src/models/report_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ReportList { /// Total number of reports that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of reports. #[serde(rename = "reports")] + #[serde(default = "default_reports")] pub reports: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_reports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ReportList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/resource_token.rs b/src/models/resource_token.rs index 2108383..4efceee 100644 --- a/src/models/resource_token.rs +++ b/src/models/resource_token.rs @@ -8,28 +8,63 @@ use serde::{Deserialize, Serialize}; pub struct ResourceToken { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Resource ID. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, /// Resource type. #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// JWT encoded string. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl ResourceToken { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/resource_token_list.rs b/src/models/resource_token_list.rs index af45953..de499c1 100644 --- a/src/models/resource_token_list.rs +++ b/src/models/resource_token_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct ResourceTokenList { /// Total number of tokens that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tokens. #[serde(rename = "tokens")] + #[serde(default = "default_tokens")] pub tokens: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tokens() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl ResourceTokenList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/row.rs b/src/models/row.rs index 6c50624..308b438 100644 --- a/src/models/row.rs +++ b/src/models/row.rs @@ -9,31 +9,66 @@ use std::collections::HashMap; pub struct Row { /// Row ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Row sequence ID. #[serde(rename = "$sequence")] + #[serde(default = "default_sequence")] pub sequence: String, /// Table ID. #[serde(rename = "$tableId")] + #[serde(default = "default_table_id")] pub table_id: String, /// Database ID. #[serde(rename = "$databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Row creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Row update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Row permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, #[serde(flatten)] pub data: HashMap, } +fn default_id() -> String { + "".to_string() +} + +fn default_sequence() -> String { + "".to_string() +} + +fn default_table_id() -> String { + "".to_string() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Row { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/row_list.rs b/src/models/row_list.rs index ff8047e..1ec0e23 100644 --- a/src/models/row_list.rs +++ b/src/models/row_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RowList { /// Total number of rows that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of rows. #[serde(rename = "rows")] + #[serde(default = "default_rows")] pub rows: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_rows() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RowList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/runtime.rs b/src/models/runtime.rs index 71b88a9..d053cb1 100644 --- a/src/models/runtime.rs +++ b/src/models/runtime.rs @@ -8,30 +8,70 @@ use serde::{Deserialize, Serialize}; pub struct Runtime { /// Runtime ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Parent runtime key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Runtime Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Runtime version. #[serde(rename = "version")] + #[serde(default = "default_version")] pub version: String, /// Base Docker image used to build the runtime. #[serde(rename = "base")] + #[serde(default = "default_base")] pub base: String, /// Image name of Docker Hub. #[serde(rename = "image")] + #[serde(default = "default_image")] pub image: String, /// Name of the logo image. #[serde(rename = "logo")] + #[serde(default = "default_logo")] pub logo: String, /// List of supported architectures. #[serde(rename = "supports")] + #[serde(default = "default_supports")] pub supports: Vec, } +fn default_id() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_version() -> String { + "".to_string() +} + +fn default_base() -> String { + "".to_string() +} + +fn default_image() -> String { + "".to_string() +} + +fn default_logo() -> String { + "".to_string() +} + +fn default_supports() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl Runtime { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/runtime_list.rs b/src/models/runtime_list.rs index de7e84b..b45492d 100644 --- a/src/models/runtime_list.rs +++ b/src/models/runtime_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct RuntimeList { /// Total number of runtimes that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of runtimes. #[serde(rename = "runtimes")] + #[serde(default = "default_runtimes")] pub runtimes: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_runtimes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl RuntimeList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/session.rs b/src/models/session.rs index 228fc31..3a775e0 100644 --- a/src/models/session.rs +++ b/src/models/session.rs @@ -8,97 +8,242 @@ use serde::{Deserialize, Serialize}; pub struct Session { /// Session ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Session creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Session update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Session expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Session Provider. #[serde(rename = "provider")] + #[serde(default = "default_provider")] pub provider: String, /// Session Provider User ID. #[serde(rename = "providerUid")] + #[serde(default = "default_provider_uid")] pub provider_uid: String, /// Session Provider Access Token. #[serde(rename = "providerAccessToken")] + #[serde(default = "default_provider_access_token")] pub provider_access_token: String, /// The date of when the access token expires in ISO 8601 format. #[serde(rename = "providerAccessTokenExpiry")] + #[serde(default = "default_provider_access_token_expiry")] pub provider_access_token_expiry: String, /// Session Provider Refresh Token. #[serde(rename = "providerRefreshToken")] + #[serde(default = "default_provider_refresh_token")] pub provider_refresh_token: String, /// IP in use when the session was created. #[serde(rename = "ip")] + #[serde(default = "default_ip")] pub ip: String, /// Operating system code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). #[serde(rename = "osCode")] + #[serde(default = "default_os_code")] pub os_code: String, /// Operating system name. #[serde(rename = "osName")] + #[serde(default = "default_os_name")] pub os_name: String, /// Operating system version. #[serde(rename = "osVersion")] + #[serde(default = "default_os_version")] pub os_version: String, /// Client type. #[serde(rename = "clientType")] + #[serde(default = "default_client_type")] pub client_type: String, /// Client code name. View list of [available /// options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). #[serde(rename = "clientCode")] + #[serde(default = "default_client_code")] pub client_code: String, /// Client name. #[serde(rename = "clientName")] + #[serde(default = "default_client_name")] pub client_name: String, /// Client version. #[serde(rename = "clientVersion")] + #[serde(default = "default_client_version")] pub client_version: String, /// Client engine name. #[serde(rename = "clientEngine")] + #[serde(default = "default_client_engine")] pub client_engine: String, /// Client engine name. #[serde(rename = "clientEngineVersion")] + #[serde(default = "default_client_engine_version")] pub client_engine_version: String, /// Device name. #[serde(rename = "deviceName")] + #[serde(default = "default_device_name")] pub device_name: String, /// Device brand name. #[serde(rename = "deviceBrand")] + #[serde(default = "default_device_brand")] pub device_brand: String, /// Device model name. #[serde(rename = "deviceModel")] + #[serde(default = "default_device_model")] pub device_model: String, /// Country two-character ISO 3166-1 alpha code. #[serde(rename = "countryCode")] + #[serde(default = "default_country_code")] pub country_code: String, /// Country name. #[serde(rename = "countryName")] + #[serde(default = "default_country_name")] pub country_name: String, /// Returns true if this the current user session. #[serde(rename = "current")] + #[serde(default = "default_current")] pub current: bool, /// Returns a list of active session factors. #[serde(rename = "factors")] + #[serde(default = "default_factors")] pub factors: Vec, /// Secret used to authenticate the user. Only included if the request was made /// with an API key #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Most recent date in ISO 8601 format when the session successfully passed /// MFA challenge. #[serde(rename = "mfaUpdatedAt")] + #[serde(default = "default_mfa_updated_at")] pub mfa_updated_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_provider() -> String { + "".to_string() +} + +fn default_provider_uid() -> String { + "".to_string() +} + +fn default_provider_access_token() -> String { + "".to_string() +} + +fn default_provider_access_token_expiry() -> String { + "".to_string() +} + +fn default_provider_refresh_token() -> String { + "".to_string() +} + +fn default_ip() -> String { + "".to_string() +} + +fn default_os_code() -> String { + "".to_string() +} + +fn default_os_name() -> String { + "".to_string() +} + +fn default_os_version() -> String { + "".to_string() +} + +fn default_client_type() -> String { + "".to_string() +} + +fn default_client_code() -> String { + "".to_string() +} + +fn default_client_name() -> String { + "".to_string() +} + +fn default_client_version() -> String { + "".to_string() +} + +fn default_client_engine() -> String { + "".to_string() +} + +fn default_client_engine_version() -> String { + "".to_string() +} + +fn default_device_name() -> String { + "".to_string() +} + +fn default_device_brand() -> String { + "".to_string() +} + +fn default_device_model() -> String { + "".to_string() +} + +fn default_country_code() -> String { + "".to_string() +} + +fn default_country_name() -> String { + "".to_string() +} + +fn default_current() -> bool { + false +} + +fn default_factors() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_mfa_updated_at() -> String { + "".to_string() +} + impl Session { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/session_list.rs b/src/models/session_list.rs index 8e912c5..f74e7d3 100644 --- a/src/models/session_list.rs +++ b/src/models/session_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SessionList { /// Total number of sessions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sessions. #[serde(rename = "sessions")] + #[serde(default = "default_sessions")] pub sessions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sessions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SessionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/site.rs b/src/models/site.rs index 4cb6f80..a1f7723 100644 --- a/src/models/site.rs +++ b/src/models/site.rs @@ -8,112 +8,145 @@ use serde::{Deserialize, Serialize}; pub struct Site { /// Site ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Site creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Site update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Site name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Site enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Is the site deployed with the latest configuration? This is set to false if /// you've changed an environment variables, entrypoint, commands, or other /// settings that needs redeploy to be applied. When the value is false, /// redeploy the site to update it with the latest configuration. #[serde(rename = "live")] + #[serde(default = "default_live")] pub live: bool, /// When disabled, request logs will exclude logs and errors, and site /// responses will be slightly faster. #[serde(rename = "logging")] + #[serde(default = "default_logging")] pub logging: bool, /// Site framework. #[serde(rename = "framework")] + #[serde(default = "default_framework")] pub framework: String, /// How many days to keep the non-active deployments before they will be /// automatically deleted. #[serde(rename = "deploymentRetention")] + #[serde(default = "default_deployment_retention")] pub deployment_retention: i64, /// Site's active deployment ID. #[serde(rename = "deploymentId")] + #[serde(default = "default_deployment_id")] pub deployment_id: String, /// Active deployment creation date in ISO 8601 format. #[serde(rename = "deploymentCreatedAt")] + #[serde(default = "default_deployment_created_at")] pub deployment_created_at: String, /// Screenshot of active deployment with light theme preference file ID. #[serde(rename = "deploymentScreenshotLight")] + #[serde(default = "default_deployment_screenshot_light")] pub deployment_screenshot_light: String, /// Screenshot of active deployment with dark theme preference file ID. #[serde(rename = "deploymentScreenshotDark")] + #[serde(default = "default_deployment_screenshot_dark")] pub deployment_screenshot_dark: String, /// Site's latest deployment ID. #[serde(rename = "latestDeploymentId")] + #[serde(default = "default_latest_deployment_id")] pub latest_deployment_id: String, /// Latest deployment creation date in ISO 8601 format. #[serde(rename = "latestDeploymentCreatedAt")] + #[serde(default = "default_latest_deployment_created_at")] pub latest_deployment_created_at: String, /// Status of latest deployment. Possible values are "waiting", "processing", /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] + #[serde(default = "default_latest_deployment_status")] pub latest_deployment_status: String, /// Allowed permission scopes. #[serde(rename = "scopes")] + #[serde(default = "default_scopes")] pub scopes: Vec, /// Site variables. #[serde(rename = "vars")] + #[serde(default = "default_vars")] pub vars: Vec, /// Site request timeout in seconds. #[serde(rename = "timeout")] + #[serde(default = "default_timeout")] pub timeout: i64, /// The install command used to install the site dependencies. #[serde(rename = "installCommand")] + #[serde(default = "default_install_command")] pub install_command: String, /// The build command used to build the site. #[serde(rename = "buildCommand")] + #[serde(default = "default_build_command")] pub build_command: String, /// Custom command to use when starting site runtime. #[serde(rename = "startCommand")] + #[serde(default = "default_start_command")] pub start_command: String, /// The directory where the site build output is located. #[serde(rename = "outputDirectory")] + #[serde(default = "default_output_directory")] pub output_directory: String, /// Site VCS (Version Control System) installation id. #[serde(rename = "installationId")] + #[serde(default = "default_installation_id")] pub installation_id: String, /// VCS (Version Control System) Repository ID #[serde(rename = "providerRepositoryId")] + #[serde(default = "default_provider_repository_id")] pub provider_repository_id: String, /// VCS (Version Control System) branch name #[serde(rename = "providerBranch")] + #[serde(default = "default_provider_branch")] pub provider_branch: String, /// Path to site in VCS (Version Control System) repository #[serde(rename = "providerRootDirectory")] + #[serde(default = "default_provider_root_directory")] pub provider_root_directory: String, /// Is VCS (Version Control System) connection is in silent mode? When in /// silence mode, no comments will be posted on the repository pull or merge /// requests #[serde(rename = "providerSilentMode")] + #[serde(default = "default_provider_silent_mode")] pub provider_silent_mode: bool, /// List of branch name patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all branches. #[serde(rename = "providerBranches")] + #[serde(default = "default_provider_branches")] pub provider_branches: Vec, /// List of file path patterns that trigger automatic deployments. Supports /// glob wildcards. Empty list deploys on all file changes. #[serde(rename = "providerPaths")] + #[serde(default = "default_provider_paths")] pub provider_paths: Vec, /// Machine specification for deployment builds. #[serde(rename = "buildSpecification")] + #[serde(default = "default_build_specification")] pub build_specification: String, /// Machine specification for SSR executions. #[serde(rename = "runtimeSpecification")] + #[serde(default = "default_runtime_specification")] pub runtime_specification: String, /// Site build runtime. #[serde(rename = "buildRuntime")] + #[serde(default = "default_build_runtime")] pub build_runtime: String, /// Site framework adapter. #[serde(rename = "adapter")] @@ -124,6 +157,138 @@ pub struct Site { pub fallback_file: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_live() -> bool { + true +} + +fn default_logging() -> bool { + true +} + +fn default_framework() -> String { + "".to_string() +} + +fn default_deployment_retention() -> i64 { + 0 +} + +fn default_deployment_id() -> String { + "".to_string() +} + +fn default_deployment_created_at() -> String { + "".to_string() +} + +fn default_deployment_screenshot_light() -> String { + "".to_string() +} + +fn default_deployment_screenshot_dark() -> String { + "".to_string() +} + +fn default_latest_deployment_id() -> String { + "".to_string() +} + +fn default_latest_deployment_created_at() -> String { + "".to_string() +} + +fn default_latest_deployment_status() -> String { + "".to_string() +} + +fn default_scopes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_vars() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_timeout() -> i64 { + 15 +} + +fn default_install_command() -> String { + "".to_string() +} + +fn default_build_command() -> String { + "".to_string() +} + +fn default_start_command() -> String { + "".to_string() +} + +fn default_output_directory() -> String { + "".to_string() +} + +fn default_installation_id() -> String { + "".to_string() +} + +fn default_provider_repository_id() -> String { + "".to_string() +} + +fn default_provider_branch() -> String { + "".to_string() +} + +fn default_provider_root_directory() -> String { + "".to_string() +} + +fn default_provider_silent_mode() -> bool { + false +} + +fn default_provider_branches() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_provider_paths() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_build_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_runtime_specification() -> String { + "s-1vcpu-512mb".to_string() +} + +fn default_build_runtime() -> String { + "".to_string() +} + impl Site { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/site_list.rs b/src/models/site_list.rs index 1525368..ac1e2eb 100644 --- a/src/models/site_list.rs +++ b/src/models/site_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SiteList { /// Total number of sites that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of sites. #[serde(rename = "sites")] + #[serde(default = "default_sites")] pub sites: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_sites() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SiteList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/specification.rs b/src/models/specification.rs index 1cbb8a2..006eaf5 100644 --- a/src/models/specification.rs +++ b/src/models/specification.rs @@ -8,18 +8,38 @@ use serde::{Deserialize, Serialize}; pub struct Specification { /// Memory size in MB. #[serde(rename = "memory")] + #[serde(default = "default_memory")] pub memory: i64, /// Number of CPUs. #[serde(rename = "cpus")] + #[serde(default = "default_cpus")] pub cpus: f64, /// Is size enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Size slug. #[serde(rename = "slug")] + #[serde(default = "default_slug")] pub slug: String, } +fn default_memory() -> i64 { + 0 +} + +fn default_cpus() -> f64 { + 0.0 +} + +fn default_enabled() -> bool { + false +} + +fn default_slug() -> String { + "".to_string() +} + impl Specification { /// Get memory pub fn memory(&self) -> &i64 { diff --git a/src/models/specification_list.rs b/src/models/specification_list.rs index de28440..887dc11 100644 --- a/src/models/specification_list.rs +++ b/src/models/specification_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SpecificationList { /// Total number of specifications that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of specifications. #[serde(rename = "specifications")] + #[serde(default = "default_specifications")] pub specifications: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_specifications() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SpecificationList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/subscriber.rs b/src/models/subscriber.rs index 00b5d42..ed5a3b1 100644 --- a/src/models/subscriber.rs +++ b/src/models/subscriber.rs @@ -8,34 +8,74 @@ use serde::{Deserialize, Serialize}; pub struct Subscriber { /// Subscriber ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Subscriber creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Subscriber update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target ID. #[serde(rename = "targetId")] + #[serde(default = "default_target_id")] pub target_id: String, /// Target. #[serde(rename = "target")] pub target: crate::models::Target, /// Topic ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// User Name. #[serde(rename = "userName")] + #[serde(default = "default_user_name")] pub user_name: String, /// Topic ID. #[serde(rename = "topicId")] + #[serde(default = "default_topic_id")] pub topic_id: String, /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_target_id() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_user_name() -> String { + "".to_string() +} + +fn default_topic_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + impl Subscriber { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/subscriber_list.rs b/src/models/subscriber_list.rs index 045c977..64636fe 100644 --- a/src/models/subscriber_list.rs +++ b/src/models/subscriber_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct SubscriberList { /// Total number of subscribers that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of subscribers. #[serde(rename = "subscribers")] + #[serde(default = "default_subscribers")] pub subscribers: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_subscribers() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl SubscriberList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/table.rs b/src/models/table.rs index 82cb1f0..1c33993 100644 --- a/src/models/table.rs +++ b/src/models/table.rs @@ -8,46 +8,106 @@ use serde::{Deserialize, Serialize}; pub struct Table { /// Table ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Table creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Table update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Table permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Table name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is /// inaccessible to users, but remains accessible to Server SDKs using API /// keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether row-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "rowSecurity")] + #[serde(default = "default_row_security")] pub row_security: bool, /// Table columns. #[serde(rename = "columns")] + #[serde(default = "default_columns")] pub columns: Vec, /// Table indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum row size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used row size in bytes based on defined columns. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_row_security() -> bool { + false +} + +fn default_columns() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + impl Table { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/table_list.rs b/src/models/table_list.rs index 73748c1..53c23be 100644 --- a/src/models/table_list.rs +++ b/src/models/table_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TableList { /// Total number of tables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of tables. #[serde(rename = "tables")] + #[serde(default = "default_tables")] pub tables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_tables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/target.rs b/src/models/target.rs index 79d2dc8..7bec4f4 100644 --- a/src/models/target.rs +++ b/src/models/target.rs @@ -8,18 +8,23 @@ use serde::{Deserialize, Serialize}; pub struct Target { /// Target ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Target creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Target update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Target Name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Provider ID. #[serde(rename = "providerId")] @@ -28,15 +33,50 @@ pub struct Target { /// The target provider type. Can be one of the following: `email`, `sms` or /// `push`. #[serde(rename = "providerType")] + #[serde(default = "default_provider_type")] pub provider_type: String, /// The target identifier. #[serde(rename = "identifier")] + #[serde(default = "default_identifier")] pub identifier: String, /// Is the target expired. #[serde(rename = "expired")] + #[serde(default = "default_expired")] pub expired: bool, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_provider_type() -> String { + "".to_string() +} + +fn default_identifier() -> String { + "".to_string() +} + +fn default_expired() -> bool { + false +} + impl Target { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/target_list.rs b/src/models/target_list.rs index a3edee5..0c7f169 100644 --- a/src/models/target_list.rs +++ b/src/models/target_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TargetList { /// Total number of targets that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of targets. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TargetList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/team.rs b/src/models/team.rs index b951756..7da273c 100644 --- a/src/models/team.rs +++ b/src/models/team.rs @@ -8,24 +8,49 @@ use serde::{Deserialize, Serialize}; pub struct Team { /// Team ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Team creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Team update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Team name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total number of team members. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// Team preferences as a key-value object #[serde(rename = "prefs")] pub prefs: crate::models::Preferences, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_total() -> i64 { + 0 +} + impl Team { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/team_list.rs b/src/models/team_list.rs index d1df58e..f128b40 100644 --- a/src/models/team_list.rs +++ b/src/models/team_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TeamList { /// Total number of teams that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of teams. #[serde(rename = "teams")] + #[serde(default = "default_teams")] pub teams: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_teams() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TeamList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/token.rs b/src/models/token.rs index 89f96f4..903214a 100644 --- a/src/models/token.rs +++ b/src/models/token.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct Token { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. This will return an empty string unless the response is /// returned using an API key or as part of a webhook payload. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl Token { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/token_secret.rs b/src/models/token_secret.rs index 442416e..de2563e 100644 --- a/src/models/token_secret.rs +++ b/src/models/token_secret.rs @@ -8,27 +8,57 @@ use serde::{Deserialize, Serialize}; pub struct TokenSecret { /// Token ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Token creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User ID. #[serde(rename = "userId")] + #[serde(default = "default_user_id")] pub user_id: String, /// Token secret key. Exchange it for a session with the create session /// endpoint. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Token expiration date in ISO 8601 format. #[serde(rename = "expire")] + #[serde(default = "default_expire")] pub expire: String, /// Security phrase of a token. Empty if security phrase was not requested when /// creating a token. It includes randomly generated phrase which is also sent /// in the external resource such as email. #[serde(rename = "phrase")] + #[serde(default = "default_phrase")] pub phrase: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_user_id() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_phrase() -> String { + "".to_string() +} + impl TokenSecret { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic.rs b/src/models/topic.rs index 976d41b..ea701c4 100644 --- a/src/models/topic.rs +++ b/src/models/topic.rs @@ -8,39 +8,81 @@ use serde::{Deserialize, Serialize}; pub struct Topic { /// Topic ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Topic creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Topic update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// The name of the topic. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Total count of email subscribers subscribed to the topic. #[serde(rename = "emailTotal")] + #[serde(default = "default_email_total")] pub email_total: i64, /// Total count of SMS subscribers subscribed to the topic. #[serde(rename = "smsTotal")] + #[serde(default = "default_sms_total")] pub sms_total: i64, /// Total count of push subscribers subscribed to the topic. #[serde(rename = "pushTotal")] + #[serde(default = "default_push_total")] pub push_total: i64, /// Subscribe permissions. #[serde(rename = "subscribe")] + #[serde(default = "default_subscribe")] pub subscribe: Vec, /// MQTT QoS for delivery on this topic. Null lets the subscriber choose their /// level. #[serde(rename = "qos")] #[serde(skip_serializing_if = "Option::is_none")] pub qos: Option, - /// Message retention in seconds for offline delivery. + /// Message retention in seconds for offline delivery. Null inherits the lowest + /// expiry of the project's enabled Appwrite providers, or the 7-day ledger + /// window if none sets one. #[serde(rename = "expiry")] #[serde(skip_serializing_if = "Option::is_none")] pub expiry: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_email_total() -> i64 { + 0 +} + +fn default_sms_total() -> i64 { + 0 +} + +fn default_push_total() -> i64 { + 0 +} + +fn default_subscribe() -> Vec { + serde_json::from_value(serde_json::json!(["users"])).unwrap() +} + impl Topic { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/topic_list.rs b/src/models/topic_list.rs index 824d84b..b7e128d 100644 --- a/src/models/topic_list.rs +++ b/src/models/topic_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TopicList { /// Total number of topics that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of topics. #[serde(rename = "topics")] + #[serde(default = "default_topics")] pub topics: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_topics() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TopicList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/transaction.rs b/src/models/transaction.rs index bb2272a..e034fe3 100644 --- a/src/models/transaction.rs +++ b/src/models/transaction.rs @@ -8,25 +8,55 @@ use serde::{Deserialize, Serialize}; pub struct Transaction { /// Transaction ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Transaction creation time in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Transaction update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Current status of the transaction. One of: pending, committing, committed, /// rolled_back, failed. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: String, /// Number of operations in the transaction. #[serde(rename = "operations")] + #[serde(default = "default_operations")] pub operations: i64, /// Expiration time in ISO 8601 format. #[serde(rename = "expiresAt")] + #[serde(default = "default_expires_at")] pub expires_at: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_status() -> String { + "pending".to_string() +} + +fn default_operations() -> i64 { + 0 +} + +fn default_expires_at() -> String { + "".to_string() +} + impl Transaction { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/transaction_list.rs b/src/models/transaction_list.rs index 29cab9e..6ebd9a0 100644 --- a/src/models/transaction_list.rs +++ b/src/models/transaction_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct TransactionList { /// Total number of transactions that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of transactions. #[serde(rename = "transactions")] + #[serde(default = "default_transactions")] pub transactions: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_transactions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl TransactionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/usage_billing_plan.rs b/src/models/usage_billing_plan.rs index ab2c459..ead81be 100644 --- a/src/models/usage_billing_plan.rs +++ b/src/models/usage_billing_plan.rs @@ -8,36 +8,44 @@ use serde::{Deserialize, Serialize}; pub struct UsageBillingPlan { /// Bandwidth additional resources #[serde(rename = "bandwidth")] - pub bandwidth: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub bandwidth: Option, /// Executions additional resources #[serde(rename = "executions")] - pub executions: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub executions: Option, /// Member additional resources #[serde(rename = "member")] #[serde(skip_serializing_if = "Option::is_none")] pub member: Option, /// Realtime additional resources #[serde(rename = "realtime")] - pub realtime: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime: Option, /// Realtime messages additional resources #[serde(rename = "realtimeMessages")] - pub realtime_messages: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub realtime_messages: Option, /// Realtime bandwidth additional resources #[serde(rename = "realtimeBandwidth")] #[serde(skip_serializing_if = "Option::is_none")] pub realtime_bandwidth: Option, /// Storage additional resources #[serde(rename = "storage")] - pub storage: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub storage: Option, /// User additional resources #[serde(rename = "users")] - pub users: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub users: Option, /// GBHour additional resources #[serde(rename = "GBHours")] - pub gb_hours: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub gb_hours: Option, /// Image transformation additional resources #[serde(rename = "imageTransformations")] - pub image_transformations: crate::models::AdditionalResource, + #[serde(skip_serializing_if = "Option::is_none")] + pub image_transformations: Option, /// Credits additional resources #[serde(rename = "credits")] #[serde(skip_serializing_if = "Option::is_none")] @@ -45,14 +53,26 @@ pub struct UsageBillingPlan { } impl UsageBillingPlan { + /// Set bandwidth + pub fn set_bandwidth(mut self, bandwidth: crate::models::AdditionalResource) -> Self { + self.bandwidth = Some(bandwidth); + self + } + /// Get bandwidth - pub fn bandwidth(&self) -> &crate::models::AdditionalResource { - &self.bandwidth + pub fn bandwidth(&self) -> Option<&crate::models::AdditionalResource> { + self.bandwidth.as_ref() + } + + /// Set executions + pub fn set_executions(mut self, executions: crate::models::AdditionalResource) -> Self { + self.executions = Some(executions); + self } /// Get executions - pub fn executions(&self) -> &crate::models::AdditionalResource { - &self.executions + pub fn executions(&self) -> Option<&crate::models::AdditionalResource> { + self.executions.as_ref() } /// Set member @@ -66,14 +86,29 @@ impl UsageBillingPlan { self.member.as_ref() } + /// Set realtime + pub fn set_realtime(mut self, realtime: crate::models::AdditionalResource) -> Self { + self.realtime = Some(realtime); + self + } + /// Get realtime - pub fn realtime(&self) -> &crate::models::AdditionalResource { - &self.realtime + pub fn realtime(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime.as_ref() + } + + /// Set realtime_messages + pub fn set_realtime_messages( + mut self, + realtime_messages: crate::models::AdditionalResource, + ) -> Self { + self.realtime_messages = Some(realtime_messages); + self } /// Get realtime_messages - pub fn realtime_messages(&self) -> &crate::models::AdditionalResource { - &self.realtime_messages + pub fn realtime_messages(&self) -> Option<&crate::models::AdditionalResource> { + self.realtime_messages.as_ref() } /// Set realtime_bandwidth @@ -90,24 +125,51 @@ impl UsageBillingPlan { self.realtime_bandwidth.as_ref() } + /// Set storage + pub fn set_storage(mut self, storage: crate::models::AdditionalResource) -> Self { + self.storage = Some(storage); + self + } + /// Get storage - pub fn storage(&self) -> &crate::models::AdditionalResource { - &self.storage + pub fn storage(&self) -> Option<&crate::models::AdditionalResource> { + self.storage.as_ref() + } + + /// Set users + pub fn set_users(mut self, users: crate::models::AdditionalResource) -> Self { + self.users = Some(users); + self } /// Get users - pub fn users(&self) -> &crate::models::AdditionalResource { - &self.users + pub fn users(&self) -> Option<&crate::models::AdditionalResource> { + self.users.as_ref() + } + + /// Set gb_hours + pub fn set_gb_hours(mut self, gb_hours: crate::models::AdditionalResource) -> Self { + self.gb_hours = Some(gb_hours); + self } /// Get gb_hours - pub fn gb_hours(&self) -> &crate::models::AdditionalResource { - &self.gb_hours + pub fn gb_hours(&self) -> Option<&crate::models::AdditionalResource> { + self.gb_hours.as_ref() + } + + /// Set image_transformations + pub fn set_image_transformations( + mut self, + image_transformations: crate::models::AdditionalResource, + ) -> Self { + self.image_transformations = Some(image_transformations); + self } /// Get image_transformations - pub fn image_transformations(&self) -> &crate::models::AdditionalResource { - &self.image_transformations + pub fn image_transformations(&self) -> Option<&crate::models::AdditionalResource> { + self.image_transformations.as_ref() } /// Set credits @@ -129,14 +191,6 @@ mod tests { #[test] fn test_usage_billing_plan_creation() { let _model = ::default(); - let _ = _model.bandwidth(); - let _ = _model.executions(); - let _ = _model.realtime(); - let _ = _model.realtime_messages(); - let _ = _model.storage(); - let _ = _model.users(); - let _ = _model.gb_hours(); - let _ = _model.image_transformations(); } #[test] diff --git a/src/models/user.rs b/src/models/user.rs index d6e6d2e..9bcaa78 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -8,15 +8,19 @@ use serde::{Deserialize, Serialize}; pub struct User { /// User ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// User creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// User update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// User name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Hashed user password. #[serde(rename = "password")] @@ -32,24 +36,31 @@ pub struct User { pub hash_options: Option, /// User registration date in ISO 8601 format. #[serde(rename = "registration")] + #[serde(default = "default_registration")] pub registration: String, /// User status. Pass `true` for enabled and `false` for disabled. #[serde(rename = "status")] + #[serde(default = "default_status")] pub status: bool, /// Labels for the user. #[serde(rename = "labels")] + #[serde(default = "default_labels")] pub labels: Vec, /// Password update time in ISO 8601 format. #[serde(rename = "passwordUpdate")] + #[serde(default = "default_password_update")] pub password_update: String, /// User email address. #[serde(rename = "email")] + #[serde(default = "default_email")] pub email: String, /// User phone number in E.164 format. #[serde(rename = "phone")] + #[serde(default = "default_phone")] pub phone: String, /// Email verification status. #[serde(rename = "emailVerification")] + #[serde(default = "default_email_verification")] pub email_verification: bool, /// Canonical form of the user email address. #[serde(rename = "emailCanonical")] @@ -78,9 +89,11 @@ pub struct User { pub password_pwned: Option, /// Phone verification status. #[serde(rename = "phoneVerification")] + #[serde(default = "default_phone_verification")] pub phone_verification: bool, /// Multi factor authentication status. #[serde(rename = "mfa")] + #[serde(default = "default_mfa")] pub mfa: bool, /// User preferences as a key-value object #[serde(rename = "prefs")] @@ -88,10 +101,12 @@ pub struct User { /// A user-owned message receiver. A single user may have multiple e.g. emails, /// phones, and a browser. Each target is registered with a single provider. #[serde(rename = "targets")] + #[serde(default = "default_targets")] pub targets: Vec, /// Most recent access date in ISO 8601 format. This attribute is only updated /// again after 24 hours. #[serde(rename = "accessedAt")] + #[serde(default = "default_accessed_at")] pub accessed_at: String, /// Whether the user can impersonate other users. #[serde(rename = "impersonator")] @@ -106,6 +121,66 @@ pub struct User { pub impersonator_user_id: Option, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_registration() -> String { + "".to_string() +} + +fn default_status() -> bool { + true +} + +fn default_labels() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_password_update() -> String { + "".to_string() +} + +fn default_email() -> String { + "".to_string() +} + +fn default_phone() -> String { + "".to_string() +} + +fn default_email_verification() -> bool { + false +} + +fn default_phone_verification() -> bool { + false +} + +fn default_mfa() -> bool { + false +} + +fn default_targets() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_accessed_at() -> String { + "".to_string() +} + impl User { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/user_list.rs b/src/models/user_list.rs index a6e27f4..16c8f64 100644 --- a/src/models/user_list.rs +++ b/src/models/user_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct UserList { /// Total number of users that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of users. #[serde(rename = "users")] + #[serde(default = "default_users")] pub users: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_users() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl UserList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/variable.rs b/src/models/variable.rs index cadb289..b27a858 100644 --- a/src/models/variable.rs +++ b/src/models/variable.rs @@ -8,33 +8,73 @@ use serde::{Deserialize, Serialize}; pub struct Variable { /// Variable ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Variable creation date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Variable key. #[serde(rename = "key")] + #[serde(default = "default_key")] pub key: String, /// Variable value. #[serde(rename = "value")] + #[serde(default = "default_value")] pub value: String, /// Variable secret flag. Secret variables can only be updated or deleted, but /// never read. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: bool, /// Service to which the variable belongs. Possible values are "project", /// "function" #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] pub resource_type: String, /// ID of resource to which the variable belongs. If resourceType is "project", /// it is empty. If resourceType is "function", it is ID of the function. #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] pub resource_id: String, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_key() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + +fn default_secret() -> bool { + false +} + +fn default_resource_type() -> String { + "".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + impl Variable { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/variable_list.rs b/src/models/variable_list.rs index 9720690..3c3a8bf 100644 --- a/src/models/variable_list.rs +++ b/src/models/variable_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VariableList { /// Total number of variables that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of variables. #[serde(rename = "variables")] + #[serde(default = "default_variables")] pub variables: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_variables() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VariableList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/vectorsdb_collection.rs b/src/models/vectorsdb_collection.rs index f352907..38e0c83 100644 --- a/src/models/vectorsdb_collection.rs +++ b/src/models/vectorsdb_collection.rs @@ -8,49 +8,114 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollection { /// Collection ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Collection creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Collection update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Collection permissions. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "$permissions")] + #[serde(default = "default_permissions")] pub permissions: Vec, /// Database ID. #[serde(rename = "databaseId")] + #[serde(default = "default_database_id")] pub database_id: String, /// Collection name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the /// collection is inaccessible to users, but remains accessible to Server SDKs /// using API keys. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Whether document-level permissions are enabled. [Learn more about /// permissions](https://appwrite.io/docs/permissions). #[serde(rename = "documentSecurity")] + #[serde(default = "default_document_security")] pub document_security: bool, /// Collection attributes. #[serde(rename = "attributes")] + #[serde(default = "default_attributes")] pub attributes: Vec, /// Collection indexes. #[serde(rename = "indexes")] + #[serde(default = "default_indexes")] pub indexes: Vec, /// Maximum document size in bytes. Returns 0 when no limit applies. #[serde(rename = "bytesMax")] + #[serde(default = "default_bytes_max")] pub bytes_max: i64, /// Currently used document size in bytes based on defined attributes. #[serde(rename = "bytesUsed")] + #[serde(default = "default_bytes_used")] pub bytes_used: i64, /// Embedding dimension. #[serde(rename = "dimension")] + #[serde(default = "default_dimension")] pub dimension: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_permissions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_database_id() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_document_security() -> bool { + false +} + +fn default_attributes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_indexes() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_bytes_max() -> i64 { + 0 +} + +fn default_bytes_used() -> i64 { + 0 +} + +fn default_dimension() -> i64 { + 0 +} + impl VectorsdbCollection { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/vectorsdb_collection_list.rs b/src/models/vectorsdb_collection_list.rs index 719dfca..09c5647 100644 --- a/src/models/vectorsdb_collection_list.rs +++ b/src/models/vectorsdb_collection_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct VectorsdbCollectionList { /// Total number of collections that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of collections. #[serde(rename = "collections")] + #[serde(default = "default_collections")] pub collections: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_collections() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl VectorsdbCollectionList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/models/webhook.rs b/src/models/webhook.rs index 5e398a3..3875de3 100644 --- a/src/models/webhook.rs +++ b/src/models/webhook.rs @@ -8,46 +8,111 @@ use serde::{Deserialize, Serialize}; pub struct Webhook { /// Webhook ID. #[serde(rename = "$id")] + #[serde(default = "default_id")] pub id: String, /// Webhook creation date in ISO 8601 format. #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] pub created_at: String, /// Webhook update date in ISO 8601 format. #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] pub updated_at: String, /// Webhook name. #[serde(rename = "name")] + #[serde(default = "default_name")] pub name: String, /// Webhook URL endpoint. #[serde(rename = "url")] + #[serde(default = "default_url")] pub url: String, /// Webhook trigger events. #[serde(rename = "events")] + #[serde(default = "default_events")] pub events: Vec, /// Indicates if SSL / TLS certificate verification is enabled. #[serde(rename = "tls")] + #[serde(default = "default_tls")] pub tls: bool, /// HTTP basic authentication username. #[serde(rename = "authUsername")] + #[serde(default = "default_auth_username")] pub auth_username: String, - /// HTTP basic authentication password. + /// HTTP basic authentication password. Write-only: always returned empty. #[serde(rename = "authPassword")] + #[serde(default = "default_auth_password")] pub auth_password: String, /// Signature key which can be used to validate incoming webhook payloads. Only /// returned on creation and secret rotation. #[serde(rename = "secret")] + #[serde(default = "default_secret")] pub secret: String, /// Indicates if this webhook is enabled. #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] pub enabled: bool, /// Webhook error logs from the most recent failure. #[serde(rename = "logs")] + #[serde(default = "default_logs")] pub logs: String, /// Number of consecutive failed webhook attempts. #[serde(rename = "attempts")] + #[serde(default = "default_attempts")] pub attempts: i64, } +fn default_id() -> String { + "".to_string() +} + +fn default_created_at() -> String { + "".to_string() +} + +fn default_updated_at() -> String { + "".to_string() +} + +fn default_name() -> String { + "".to_string() +} + +fn default_url() -> String { + "".to_string() +} + +fn default_events() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_tls() -> bool { + true +} + +fn default_auth_username() -> String { + "".to_string() +} + +fn default_auth_password() -> String { + "".to_string() +} + +fn default_secret() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_logs() -> String { + "".to_string() +} + +fn default_attempts() -> i64 { + 0 +} + impl Webhook { /// Get id pub fn id(&self) -> &String { diff --git a/src/models/webhook_list.rs b/src/models/webhook_list.rs index 29d04f7..d9602c4 100644 --- a/src/models/webhook_list.rs +++ b/src/models/webhook_list.rs @@ -8,12 +8,22 @@ use serde::{Deserialize, Serialize}; pub struct WebhookList { /// Total number of webhooks that matched your query. #[serde(rename = "total")] + #[serde(default = "default_total")] pub total: i64, /// List of webhooks. #[serde(rename = "webhooks")] + #[serde(default = "default_webhooks")] pub webhooks: Vec, } +fn default_total() -> i64 { + 0 +} + +fn default_webhooks() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + impl WebhookList { /// Get total pub fn total(&self) -> &i64 { diff --git a/src/query/builder.rs b/src/query/builder.rs new file mode 100644 index 0000000..ea55fad --- /dev/null +++ b/src/query/builder.rs @@ -0,0 +1,622 @@ +use serde::Serialize; +use serde_json::Value; + +use super::Query; + +#[derive(Debug, Clone, Default)] +pub struct Builder { + queries: Vec, +} + +impl Builder { + pub fn new() -> Self { + Self { + queries: Vec::new(), + } + } + + pub fn build(&self) -> Vec { + self.queries.iter().map(|query| query.to_string()).collect() + } + + pub fn equal, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::equal(attribute, value)); + self + } + + pub fn not_equal, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::not_equal(attribute, value)); + self + } + + pub fn less_than, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::less_than(attribute, value)); + self + } + + pub fn less_than_equal, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries.push(Query::less_than_equal(attribute, value)); + self + } + + pub fn greater_than, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::greater_than(attribute, value)); + self + } + + pub fn greater_than_equal, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries + .push(Query::greater_than_equal(attribute, value)); + self + } + + pub fn is_null>(mut self, attribute: S) -> Self { + self.queries.push(Query::is_null(attribute)); + self + } + + pub fn is_not_null>(mut self, attribute: S) -> Self { + self.queries.push(Query::is_not_null(attribute)); + self + } + + pub fn between, V: Into>( + mut self, + attribute: S, + start: V, + end: V, + ) -> Self { + self.queries.push(Query::between(attribute, start, end)); + self + } + + pub fn starts_with, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::starts_with(attribute, value)); + self + } + + pub fn ends_with, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::ends_with(attribute, value)); + self + } + + pub fn select, S: Into>(mut self, attributes: I) -> Self { + self.queries.push(Query::select(attributes)); + self + } + + pub fn search, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::search(attribute, value)); + self + } + + pub fn not_search, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::not_search(attribute, value)); + self + } + + pub fn order_asc>(mut self, attribute: S) -> Self { + self.queries.push(Query::order_asc(attribute)); + self + } + + pub fn order_desc>(mut self, attribute: S) -> Self { + self.queries.push(Query::order_desc(attribute)); + self + } + + pub fn order_random(mut self) -> Self { + self.queries.push(Query::order_random()); + self + } + + pub fn cursor_after>(mut self, document_id: S) -> Self { + self.queries.push(Query::cursor_after(document_id)); + self + } + + pub fn cursor_before>(mut self, document_id: S) -> Self { + self.queries.push(Query::cursor_before(document_id)); + self + } + + pub fn limit(mut self, value: u32) -> Self { + self.queries.push(Query::limit(value)); + self + } + + pub fn offset(mut self, value: u32) -> Self { + self.queries.push(Query::offset(value)); + self + } + + pub fn contains, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::contains(attribute, value)); + self + } + + pub fn contains_any, V: Into>( + mut self, + attribute: S, + values: Vec, + ) -> Self { + self.queries.push(Query::contains_any(attribute, values)); + self + } + + pub fn contains_all, V: Into>( + mut self, + attribute: S, + values: Vec, + ) -> Self { + self.queries.push(Query::contains_all(attribute, values)); + self + } + + pub fn not_contains, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::not_contains(attribute, value)); + self + } + + pub fn not_between, V: Into>( + mut self, + attribute: S, + start: V, + end: V, + ) -> Self { + self.queries.push(Query::not_between(attribute, start, end)); + self + } + + pub fn not_starts_with, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries.push(Query::not_starts_with(attribute, value)); + self + } + + pub fn not_ends_with, V: Into>( + mut self, + attribute: S, + value: V, + ) -> Self { + self.queries.push(Query::not_ends_with(attribute, value)); + self + } + + pub fn created_before>(mut self, value: V) -> Self { + self.queries.push(Query::created_before(value)); + self + } + + pub fn created_after>(mut self, value: V) -> Self { + self.queries.push(Query::created_after(value)); + self + } + + pub fn created_between>(mut self, start: V, end: V) -> Self { + self.queries.push(Query::created_between(start, end)); + self + } + + pub fn updated_before>(mut self, value: V) -> Self { + self.queries.push(Query::updated_before(value)); + self + } + + pub fn updated_after>(mut self, value: V) -> Self { + self.queries.push(Query::updated_after(value)); + self + } + + pub fn updated_between>(mut self, start: V, end: V) -> Self { + self.queries.push(Query::updated_between(start, end)); + self + } + + pub fn distance_equal, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries + .push(Query::distance_equal(attribute, values, distance, meters)); + self + } + + pub fn distance_not_equal, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries.push(Query::distance_not_equal( + attribute, values, distance, meters, + )); + self + } + + pub fn distance_greater_than, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries.push(Query::distance_greater_than( + attribute, values, distance, meters, + )); + self + } + + pub fn distance_less_than, V: Into>( + mut self, + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { + self.queries.push(Query::distance_less_than( + attribute, values, distance, meters, + )); + self + } + + pub fn intersects, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::intersects(attribute, values)); + self + } + + pub fn not_intersects, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries.push(Query::not_intersects(attribute, values)); + self + } + + pub fn crosses, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::crosses(attribute, values)); + self + } + + pub fn not_crosses, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::not_crosses(attribute, values)); + self + } + + pub fn overlaps, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::overlaps(attribute, values)); + self + } + + pub fn not_overlaps, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries.push(Query::not_overlaps(attribute, values)); + self + } + + pub fn touches, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::touches(attribute, values)); + self + } + + pub fn not_touches, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::not_touches(attribute, values)); + self + } + + pub fn or(mut self, queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::or(queries)); + self + } + + pub fn and(mut self, queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::and(queries)); + self + } + + pub fn regex, V: Into>(mut self, attribute: S, value: V) -> Self { + self.queries.push(Query::regex(attribute, value)); + self + } + + pub fn exists>(mut self, attributes: Vec) -> Self { + self.queries.push(Query::exists(attributes)); + self + } + + pub fn not_exists>(mut self, attributes: Vec) -> Self { + self.queries.push(Query::not_exists(attributes)); + self + } + + pub fn elem_match(mut self, attribute: S, queries: I) -> Self + where + S: Into, + I: IntoIterator, + Q: AsRef, + { + self.queries.push(Query::elem_match(attribute, queries)); + self + } + + pub fn relationship(mut self, attribute: S, queries: I) -> Self + where + S: Into, + I: IntoIterator, + Q: AsRef, + { + self.queries.push(Query::relationship(attribute, queries)); + self + } + + pub fn count(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::count(attribute, alias)); + self + } + + pub fn count_distinct( + mut self, + attribute: impl Into, + alias: impl Into, + ) -> Self { + self.queries.push(Query::count_distinct(attribute, alias)); + self + } + + pub fn sum(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::sum(attribute, alias)); + self + } + + pub fn avg(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::avg(attribute, alias)); + self + } + + pub fn min(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::min(attribute, alias)); + self + } + + pub fn max(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::max(attribute, alias)); + self + } + + pub fn stddev(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::stddev(attribute, alias)); + self + } + + pub fn stddev_pop(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::stddev_pop(attribute, alias)); + self + } + + pub fn stddev_samp(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::stddev_samp(attribute, alias)); + self + } + + pub fn variance(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::variance(attribute, alias)); + self + } + + pub fn var_pop(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::var_pop(attribute, alias)); + self + } + + pub fn var_samp(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::var_samp(attribute, alias)); + self + } + + pub fn bit_and(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::bit_and(attribute, alias)); + self + } + + pub fn bit_or(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::bit_or(attribute, alias)); + self + } + + pub fn bit_xor(mut self, attribute: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::bit_xor(attribute, alias)); + self + } + + pub fn group_by(mut self, attributes: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.queries.push(Query::group_by(attributes)); + self + } + + pub fn having(mut self, queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::having(queries)); + self + } + + pub fn distinct(mut self) -> Self { + self.queries.push(Query::distinct()); + self + } + + pub fn join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::join(table, left, right, operator, alias)); + self + } + + pub fn left_join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::left_join(table, left, right, operator, alias)); + self + } + + pub fn left_join_on( + mut self, + table: impl Into, + alias: impl Into, + on: I, + ) -> Self + where + I: IntoIterator, + S: AsRef, + { + self.queries.push(Query::left_join_on(table, alias, on)); + self + } + + pub fn right_join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::right_join(table, left, right, operator, alias)); + self + } + + pub fn full_outer_join( + mut self, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + self.queries + .push(Query::full_outer_join(table, left, right, operator, alias)); + self + } + + pub fn cross_join(mut self, table: impl Into, alias: impl Into) -> Self { + self.queries.push(Query::cross_join(table, alias)); + self + } + + pub fn vector_dot, N: Into>( + mut self, + attribute: S, + vector: Vec, + ) -> Self { + let values = Value::Array(vector.into_iter().map(|n| n.into()).collect()); + self.queries.push(Query::vector_dot(attribute, values)); + self + } + + pub fn vector_cosine, N: Into>( + mut self, + attribute: S, + vector: Vec, + ) -> Self { + let values = Value::Array(vector.into_iter().map(|n| n.into()).collect()); + self.queries.push(Query::vector_cosine(attribute, values)); + self + } + + pub fn vector_euclidean, N: Into>( + mut self, + attribute: S, + vector: Vec, + ) -> Self { + let values = Value::Array(vector.into_iter().map(|n| n.into()).collect()); + self.queries + .push(Query::vector_euclidean(attribute, values)); + self + } + + pub fn covers, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::covers(attribute, values)); + self + } + + pub fn not_covers, V: Into>(mut self, attribute: S, values: V) -> Self { + self.queries.push(Query::not_covers(attribute, values)); + self + } + + pub fn spatial_equals, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries.push(Query::spatial_equals(attribute, values)); + self + } + + pub fn not_spatial_equals, V: Into>( + mut self, + attribute: S, + values: V, + ) -> Self { + self.queries + .push(Query::not_spatial_equals(attribute, values)); + self + } + + pub fn page(mut self, page: u32, per_page: u32) -> Self { + self.queries.extend(Query::page(page, per_page)); + self + } +} + +impl Serialize for Builder { + fn serialize(&self, serializer: S) -> Result { + self.build().serialize(serializer) + } +} diff --git a/src/query.rs b/src/query/mod.rs similarity index 67% rename from src/query.rs rename to src/query/mod.rs index a495391..fbfcca8 100644 --- a/src/query.rs +++ b/src/query/mod.rs @@ -3,6 +3,9 @@ use serde::Serialize; use serde_json::Value; +mod builder; +pub use builder::Builder; + /// Query builder for filtering and sorting database queries #[derive(Debug, Clone, Serialize)] pub struct Query { @@ -458,6 +461,302 @@ impl Query { Self::new("elemMatch".to_string(), Some(attribute.into()), values) } + pub fn relationship(attribute: S, queries: I) -> Self + where + S: Into, + I: IntoIterator, + Q: AsRef, + { + let values: Vec = queries + .into_iter() + .filter_map(|query| serde_json::from_str(query.as_ref()).ok()) + .collect(); + Self::new("relationship".to_string(), Some(attribute.into()), values) + } + + pub fn count(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("count", attribute, alias) + } + + pub fn count_distinct(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("countDistinct", attribute, alias) + } + + pub fn sum(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("sum", attribute, alias) + } + + pub fn avg(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("avg", attribute, alias) + } + + pub fn min(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("min", attribute, alias) + } + + pub fn max(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("max", attribute, alias) + } + + pub fn stddev(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("stddev", attribute, alias) + } + + pub fn stddev_pop(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("stddevPop", attribute, alias) + } + + pub fn stddev_samp(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("stddevSamp", attribute, alias) + } + + pub fn variance(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("variance", attribute, alias) + } + + pub fn var_pop(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("varPop", attribute, alias) + } + + pub fn var_samp(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("varSamp", attribute, alias) + } + + pub fn bit_and(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("bitAnd", attribute, alias) + } + + pub fn bit_or(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("bitOr", attribute, alias) + } + + pub fn bit_xor(attribute: impl Into, alias: impl Into) -> Self { + Self::aliased("bitXor", attribute, alias) + } + + pub fn group_by(attributes: I) -> Self + where + I: IntoIterator, + S: Into, + { + let values: Vec = attributes + .into_iter() + .map(|s| Value::String(s.into())) + .collect(); + Self::new("groupBy".to_string(), None, values) + } + + pub fn having(queries: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + let values: Vec = queries + .into_iter() + .filter_map(|query| serde_json::from_str(query.as_ref()).ok()) + .collect(); + Self::new("having".to_string(), None, values) + } + + pub fn distinct() -> Self { + Self::new("distinct".to_string(), None, vec![]) + } + + pub fn on( + left: impl Into, + right: impl Into, + operator: impl Into, + ) -> Self { + Self::new( + "on".to_string(), + None, + vec![ + Value::String(left.into()), + Value::String(operator.into()), + Value::String(right.into()), + ], + ) + } + + pub fn join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("join", table, left, right, operator, alias) + } + + pub fn left_join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("leftJoin", table, left, right, operator, alias) + } + + pub fn right_join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("rightJoin", table, left, right, operator, alias) + } + + pub fn full_outer_join( + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + Self::join_query("fullOuterJoin", table, left, right, operator, alias) + } + + pub fn cross_join(table: impl Into, alias: impl Into) -> Self { + Self::aliased("crossJoin", table, alias) + } + + pub fn join_on(table: impl Into, alias: impl Into, on: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("join", table, alias, on) + } + + pub fn left_join_on(table: impl Into, alias: impl Into, on: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("leftJoin", table, alias, on) + } + + pub fn right_join_on(table: impl Into, alias: impl Into, on: I) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("rightJoin", table, alias, on) + } + + pub fn full_outer_join_on( + table: impl Into, + alias: impl Into, + on: I, + ) -> Self + where + I: IntoIterator, + S: AsRef, + { + Self::nested_join("fullOuterJoin", table, alias, on) + } + + pub fn covers, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "covers".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn not_covers, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "notCovers".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn spatial_equals, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "spatialEquals".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn not_spatial_equals, V: Into>(attribute: S, values: V) -> Self { + Self::new( + "notSpatialEquals".to_string(), + Some(attribute.into()), + vec![values.into()], + ) + } + + pub fn page(page: u32, per_page: u32) -> Vec { + if page < 1 { + panic!("Page must be >= 1, got {}", page); + } + if per_page < 1 { + panic!("Per page must be >= 1, got {}", per_page); + } + vec![Self::limit(per_page), Self::offset((page - 1) * per_page)] + } + + pub fn builder() -> Builder { + Builder::new() + } + + fn aliased(method: &str, attribute: impl Into, alias: impl Into) -> Self { + let alias = alias.into(); + let values = if alias.is_empty() { + vec![] + } else { + vec![Value::String(alias)] + }; + Self::new(method.to_string(), Some(attribute.into()), values) + } + + fn join_query( + method: &str, + table: impl Into, + left: impl Into, + right: impl Into, + operator: impl Into, + alias: impl Into, + ) -> Self { + let mut values = vec![ + Value::String(left.into()), + Value::String(operator.into()), + Value::String(right.into()), + ]; + let alias = alias.into(); + if !alias.is_empty() { + values.push(Value::String(alias)); + } + Self::new(method.to_string(), Some(table.into()), values) + } + + fn nested_join( + method: &str, + table: impl Into, + alias: impl Into, + on: I, + ) -> Self + where + I: IntoIterator, + S: AsRef, + { + let mut values = Vec::new(); + let alias = alias.into(); + if !alias.is_empty() { + values.push(Value::String(alias)); + } + for query in on { + if let Ok(parsed) = serde_json::from_str::(query.as_ref()) { + values.push(parsed); + } + } + Self::new(method.to_string(), Some(table.into()), values) + } + /// Convert query to JSON value (matches Go/Python SDK format) pub fn to_value(self) -> Value { let mut obj = serde_json::Map::new(); @@ -1093,4 +1392,278 @@ mod tests { assert_eq!(value["attribute"], "content"); assert_eq!(value["values"][0], "spam keyword"); } + + #[test] + fn test_count_with_alias() { + let query = Query::count("*", "total"); + let value = query.to_value(); + assert_eq!(value["method"], "count"); + assert_eq!(value["attribute"], "*"); + assert_eq!(value["values"][0], "total"); + } + + #[test] + fn test_count_without_alias() { + let query = Query::count("*", ""); + let value = query.to_value(); + assert_eq!(value["method"], "count"); + assert_eq!(value["attribute"], "*"); + assert!(value.get("values").is_none()); + } + + #[test] + fn test_count_distinct() { + let value = Query::count_distinct("year", "uniqueYears").to_value(); + assert_eq!(value["method"], "countDistinct"); + assert_eq!(value["attribute"], "year"); + assert_eq!(value["values"][0], "uniqueYears"); + } + + #[test] + fn test_sum() { + assert_eq!(Query::sum("price", "total").to_value()["method"], "sum"); + } + + #[test] + fn test_avg() { + assert_eq!(Query::avg("price", "avgPrice").to_value()["method"], "avg"); + } + + #[test] + fn test_min() { + assert_eq!(Query::min("price", "lowest").to_value()["method"], "min"); + } + + #[test] + fn test_max() { + assert_eq!(Query::max("price", "highest").to_value()["method"], "max"); + } + + #[test] + fn test_stddev() { + assert_eq!(Query::stddev("price", "sd").to_value()["method"], "stddev"); + } + + #[test] + fn test_stddev_pop() { + assert_eq!( + Query::stddev_pop("price", "sdp").to_value()["method"], + "stddevPop" + ); + } + + #[test] + fn test_stddev_samp() { + assert_eq!( + Query::stddev_samp("price", "sds").to_value()["method"], + "stddevSamp" + ); + } + + #[test] + fn test_variance() { + assert_eq!( + Query::variance("price", "var").to_value()["method"], + "variance" + ); + } + + #[test] + fn test_var_pop() { + assert_eq!(Query::var_pop("price", "vp").to_value()["method"], "varPop"); + } + + #[test] + fn test_var_samp() { + assert_eq!( + Query::var_samp("price", "vs").to_value()["method"], + "varSamp" + ); + } + + #[test] + fn test_bit_and() { + assert_eq!( + Query::bit_and("flags", "band").to_value()["method"], + "bitAnd" + ); + } + + #[test] + fn test_bit_or() { + assert_eq!(Query::bit_or("flags", "bor").to_value()["method"], "bitOr"); + } + + #[test] + fn test_bit_xor() { + assert_eq!( + Query::bit_xor("flags", "bxor").to_value()["method"], + "bitXor" + ); + } + + #[test] + fn test_group_by() { + let query = Query::group_by(vec!["status", "year"]); + let value = query.to_value(); + assert_eq!(value["method"], "groupBy"); + assert_eq!(value["values"][0], "status"); + assert_eq!(value["values"][1], "year"); + } + + #[test] + fn test_having() { + let query = Query::having(vec![Query::greater_than("total", 1).to_string()]); + let value = query.to_value(); + assert_eq!(value["method"], "having"); + assert_eq!(value["values"][0]["method"], "greaterThan"); + assert_eq!(value["values"][0]["attribute"], "total"); + assert_eq!(value["values"][0]["values"][0], 1); + } + + #[test] + fn test_distinct() { + let query = Query::distinct(); + let value = query.to_value(); + assert_eq!(value["method"], "distinct"); + } + + #[test] + fn test_join() { + let query = Query::join("orders", "$id", "customerId", "=", ""); + let value = query.to_value(); + assert_eq!(value["method"], "join"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][0], "$id"); + assert_eq!(value["values"][1], "="); + assert_eq!(value["values"][2], "customerId"); + assert_eq!(value["values"].as_array().unwrap().len(), 3); + } + + #[test] + fn test_left_join_with_alias() { + let query = Query::left_join("orders", "$id", "customerId", "=", "ord"); + let value = query.to_value(); + assert_eq!(value["method"], "leftJoin"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][3], "ord"); + } + + #[test] + fn test_on() { + let query = Query::on("$id", "customerId", "="); + let value = query.to_value(); + assert_eq!(value["method"], "on"); + assert_eq!(value["values"][0], "$id"); + assert_eq!(value["values"][1], "="); + assert_eq!(value["values"][2], "customerId"); + } + + #[test] + fn test_nested_left_join() { + let query = Query::left_join_on( + "orders", + "ord", + [ + Query::on("$id", "customerId", "=").to_string(), + Query::equal("ord.status", "paid").to_string(), + ], + ); + let value = query.to_value(); + assert_eq!(value["method"], "leftJoin"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][0], "ord"); + assert_eq!(value["values"][1]["method"], "on"); + assert_eq!(value["values"][2]["method"], "equal"); + } + + #[test] + fn test_cross_join() { + let query = Query::cross_join("orders", "ord"); + let value = query.to_value(); + assert_eq!(value["method"], "crossJoin"); + assert_eq!(value["attribute"], "orders"); + assert_eq!(value["values"][0], "ord"); + } + + #[test] + fn test_right_join() { + let value = Query::right_join("orders", "$id", "customerId", "=", "").to_value(); + assert_eq!(value["method"], "rightJoin"); + assert_eq!(value["values"][0], "$id"); + assert_eq!(value["values"][1], "="); + assert_eq!(value["values"][2], "customerId"); + } + + #[test] + fn test_full_outer_join() { + let value = Query::full_outer_join("orders", "$id", "customerId", "=", "").to_value(); + assert_eq!(value["method"], "fullOuterJoin"); + } + + #[test] + fn test_not_covers() { + let value = Query::not_covers( + "location", + Value::Array(vec![Value::from(1), Value::from(2)]), + ) + .to_value(); + assert_eq!(value["method"], "notCovers"); + assert_eq!(value["values"][0][0], 1); + assert_eq!(value["values"][0][1], 2); + } + + #[test] + fn test_spatial_equals() { + let value = Query::spatial_equals( + "location", + Value::Array(vec![Value::from(1), Value::from(2)]), + ) + .to_value(); + assert_eq!(value["method"], "spatialEquals"); + } + + #[test] + fn test_not_spatial_equals() { + let value = Query::not_spatial_equals( + "location", + Value::Array(vec![Value::from(1), Value::from(2)]), + ) + .to_value(); + assert_eq!(value["method"], "notSpatialEquals"); + } + + #[test] + fn test_page() { + let queries = Query::page(2, 10); + assert_eq!(queries.len(), 2); + let limit = queries[0].clone().to_value(); + let offset = queries[1].clone().to_value(); + assert_eq!(limit["method"], "limit"); + assert_eq!(limit["values"][0], 10); + assert_eq!(offset["method"], "offset"); + assert_eq!(offset["values"][0], 10); + } + + #[test] + fn test_builder_build() { + let built = Query::builder() + .equal("status", "published") + .left_join("orders", "$id", "customerId", "=", "ord") + .count("*", "total") + .group_by(vec!["status"]) + .limit(25) + .build(); + + assert_eq!( + built, + vec![ + Query::equal("status", "published").to_string(), + Query::left_join("orders", "$id", "customerId", "=", "ord").to_string(), + Query::count("*", "total").to_string(), + Query::group_by(vec!["status"]).to_string(), + Query::limit(25).to_string(), + ] + ); + } } diff --git a/src/services/account.rs b/src/services/account.rs index 9313048..1db7444 100644 --- a/src/services/account.rs +++ b/src/services/account.rs @@ -105,9 +105,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -117,18 +127,25 @@ impl Account { /// Delete an OAuth2 consent by its unique ID. All token families issued under /// the consent are revoked, and the app must ask for consent again to regain /// access. - pub async fn delete_consent( - &self, - consent_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_consent(&self, consent_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -157,9 +174,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens" .to_string() - .replace("{consentId}", &consent_id.into().to_string()); + .replace("{consentId}", &consent_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -177,10 +204,30 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -194,16 +241,36 @@ impl Account { &self, consent_id: impl Into, token_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let consent_id = consent_id.into(); + if consent_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"consentId\"", + None, + String::new(), + )); + } + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/account/consents/{consentId}/tokens/{tokenId}" .to_string() - .replace("{consentId}", &consent_id.into().to_string()) - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{consentId}", &consent_id) + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -270,43 +337,27 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/account/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } - /// 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. - pub async fn list_logs( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/account/logs".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - /// Enable or disable MFA on an account. pub async fn update_mfa(&self, mfa: bool) -> crate::error::Result { let mut params = HashMap::new(); @@ -375,6 +426,7 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/mfa/authenticators/{type}" .to_string() @@ -928,6 +980,7 @@ impl Account { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/sessions".to_string(); @@ -958,6 +1011,9 @@ impl Account { /// 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 @@ -1137,9 +1193,19 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1158,9 +1224,19 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } + let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1176,10 +1252,21 @@ impl Account { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/account/sessions/{sessionId}" .to_string() - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1289,6 +1376,10 @@ impl Account { /// 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). diff --git a/src/services/activities.rs b/src/services/activities.rs index c9017d0..b482235 100644 --- a/src/services/activities.rs +++ b/src/services/activities.rs @@ -55,9 +55,19 @@ impl Activities { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let event_id = event_id.into(); + if event_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"eventId\"", + None, + String::new(), + )); + } + let path = "/activities/events/{eventId}" .to_string() - .replace("{eventId}", &event_id.into().to_string()); + .replace("{eventId}", &event_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/advisor.rs b/src/services/advisor.rs index 084c5f2..ae581e6 100644 --- a/src/services/advisor.rs +++ b/src/services/advisor.rs @@ -61,9 +61,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -76,10 +86,21 @@ impl Advisor { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } let path = "/reports/{reportId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -107,9 +128,19 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights" .to_string() - .replace("{reportId}", &report_id.into().to_string()); + .replace("{reportId}", &report_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -126,10 +157,30 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let report_id = report_id.into(); + if report_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"reportId\"", + None, + String::new(), + )); + } + + let insight_id = insight_id.into(); + if insight_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"insightId\"", + None, + String::new(), + )); + } + let path = "/reports/{reportId}/insights/{insightId}" .to_string() - .replace("{reportId}", &report_id.into().to_string()) - .replace("{insightId}", &insight_id.into().to_string()); + .replace("{reportId}", &report_id) + .replace("{insightId}", &insight_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/apps.rs b/src/services/apps.rs index 46c3c4b..8ed7d09 100644 --- a/src/services/apps.rs +++ b/src/services/apps.rs @@ -189,9 +189,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -301,9 +309,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -311,18 +327,23 @@ impl Apps { } /// Delete an application by its unique ID. - pub async fn delete( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}".to_string().replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -351,9 +372,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -372,10 +403,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -389,16 +440,36 @@ impl Apps { &self, app_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -423,10 +494,30 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/installations/{installationId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{installationId}", &installation_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -453,9 +544,17 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -474,9 +573,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -493,10 +600,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,16 +635,36 @@ impl Apps { &self, app_id: impl Into, key_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/keys/{keyId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{keyId}", &key_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -544,9 +691,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/labels" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -573,9 +730,19 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -592,9 +759,19 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -611,10 +788,30 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -626,16 +823,36 @@ impl Apps { &self, app_id: impl Into, secret_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let secret_id = secret_id.into(); + if secret_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"secretId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/secrets/{secretId}" .to_string() - .replace("{appId}", &app_id.into().to_string()) - .replace("{secretId}", &secret_id.into().to_string()); + .replace("{appId}", &app_id) + .replace("{secretId}", &secret_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -654,9 +871,17 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/team" - .to_string() - .replace("{appId}", &app_id.into().to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + + let path = "/apps/{appId}/team".to_string().replace("{appId}", &app_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -664,18 +889,25 @@ impl Apps { } /// Revoke all tokens for an application by its unique ID. - pub async fn delete_tokens( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_tokens(&self, app_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let app_id = app_id.into(); + if app_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"appId\"", + None, + String::new(), + )); + } + let path = "/apps/{appId}/tokens" .to_string() - .replace("{appId}", &app_id.into().to_string()); + .replace("{appId}", &app_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/avatars.rs b/src/services/avatars.rs index 60c40ab..6a529a4 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -236,9 +236,9 @@ impl Avatars { } /// 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, @@ -483,27 +483,6 @@ impl crate::services::Service for Avatars { mod tests { use super::*; - #[tokio::test] - async fn test_update_photo_sends_one_request_whatever_the_chunk_size() { - use wiremock::matchers::{method, path}; - use wiremock::{Mock, MockServer, ResponseTemplate}; - - let server = MockServer::start().await; - Mock::given(method("PUT")) - .and(path("/avatars/photo")) - .respond_with(ResponseTemplate::new(500)) - .mount(&server) - .await; - - let client = Client::new().set_endpoint(server.uri()).set_chunk_size(1); - let file = InputFile::from_bytes(vec![0u8; 10], "photo.png", Some("image/png")); - let _ = Avatars::new(&client).update_photo(file).await; - - let requests = server.received_requests().await.unwrap(); - assert_eq!(requests.len(), 1); - assert!(requests[0].headers.get("content-range").is_none()); - } - #[test] fn test_avatars_creation() { let client = Client::new(); diff --git a/src/services/backups.rs b/src/services/backups.rs index 3379cb7..20fb617 100644 --- a/src/services/backups.rs +++ b/src/services/backups.rs @@ -77,9 +77,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -87,18 +97,25 @@ impl Backups { } /// Delete an existing archive for a project. - pub async fn delete_archive( - &self, - archive_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_archive(&self, archive_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let archive_id = archive_id.into(); + if archive_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"archiveId\"", + None, + String::new(), + )); + } + let path = "/backups/archives/{archiveId}" .to_string() - .replace("{archiveId}", &archive_id.into().to_string()); + .replace("{archiveId}", &archive_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -173,9 +190,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -208,9 +235,19 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -218,18 +255,25 @@ impl Backups { } /// Delete a policy using it's ID. - pub async fn delete_policy( - &self, - policy_id: impl Into, - ) -> crate::error::Result { + pub async fn delete_policy(&self, policy_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/backups/policies/{policyId}" .to_string() - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -325,9 +369,19 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/backups/restorations/{restorationId}" .to_string() - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/databases.rs b/src/services/databases.rs index 6d30c67..c9f3774 100644 --- a/src/services/databases.rs +++ b/src/services/databases.rs @@ -134,9 +134,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -178,10 +198,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/databases/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/databases/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -221,9 +262,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -248,9 +299,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -263,10 +324,21 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -298,9 +370,19 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -348,9 +430,19 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -368,10 +460,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -413,10 +525,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -433,11 +565,32 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -465,10 +618,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -508,10 +681,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -550,11 +743,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -584,10 +807,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -617,11 +860,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -651,10 +924,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -684,11 +977,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -718,10 +1041,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -751,11 +1094,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -795,10 +1168,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -837,11 +1230,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -881,10 +1304,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -923,11 +1366,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -967,10 +1440,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1502,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1043,10 +1566,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1076,11 +1619,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1106,10 +1679,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1139,11 +1732,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1178,10 +1801,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1211,11 +1854,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1250,10 +1923,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1283,11 +1976,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1313,10 +2036,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1346,11 +2089,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1376,10 +2149,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1409,11 +2202,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1456,10 +2279,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1487,12 +2330,42 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1529,10 +2402,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1567,11 +2460,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1606,10 +2529,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1639,11 +2582,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1673,10 +2646,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1706,11 +2699,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1747,10 +2770,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1785,11 +2828,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1807,11 +2880,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1828,12 +2931,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1870,10 +3004,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1909,10 +3063,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1939,10 +3113,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1969,10 +3163,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2007,10 +3221,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2040,10 +3274,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2073,11 +3327,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2114,11 +3398,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2153,11 +3467,41 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2178,12 +3522,43 @@ impl Databases { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2216,13 +3591,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2255,13 +3670,53 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2289,10 +3744,30 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2301,7 +3776,9 @@ impl Databases { /// Creates an index on the attributes listed. Your index should include all /// the attributes you will query in a single request. - /// Attributes can be `key`, `fulltext`, and `unique`. + /// Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + /// `trigram` is only available on PostgreSQL and lets `contains`, + /// `startsWith`, and `endsWith` queries on string attributes use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2333,10 +3810,30 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2354,11 +3851,41 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2375,12 +3902,43 @@ impl Databases { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/documents_db.rs b/src/services/documents_db.rs index 6f761f7..ca88c34 100644 --- a/src/services/documents_db.rs +++ b/src/services/documents_db.rs @@ -86,8 +86,8 @@ impl DocumentsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -381,9 +463,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +493,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -444,10 +556,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -464,11 +596,32 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -505,10 +658,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -544,10 +717,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -574,10 +767,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -604,10 +817,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -642,10 +875,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -675,10 +928,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -708,11 +981,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -749,11 +1052,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -788,11 +1121,41 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -813,12 +1176,43 @@ impl DocumentsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -851,13 +1245,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -890,13 +1324,53 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + + let attribute = attribute.into(); + if attribute.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"attribute\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()) - .replace("{attribute}", &attribute.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id) + .replace("{attribute}", &attribute); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -924,10 +1398,30 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -968,10 +1462,30 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -989,11 +1503,41 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1010,12 +1554,43 @@ impl DocumentsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1044,9 +1619,19 @@ impl DocumentsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1077,9 +1662,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1096,9 +1691,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1116,9 +1721,19 @@ impl DocumentsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/documentsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/functions.rs b/src/services/functions.rs index 3dd0131..85f8f06 100644 --- a/src/services/functions.rs +++ b/src/services/functions.rs @@ -224,9 +224,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -260,6 +270,7 @@ impl Functions { runtime_specification: Option<&str>, deployment_retention: Option, interval: Option, + email_enabled: Option, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); @@ -338,13 +349,26 @@ impl Functions { if let Some(value) = interval { params.insert("interval".to_string(), json!(value)); } + if let Some(value) = email_enabled { + params.insert("emailEnabled".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -356,10 +380,21 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -379,9 +414,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployment" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -413,9 +458,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -455,12 +510,30 @@ impl Functions { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -484,9 +557,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/duplicate" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -522,9 +605,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/template" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -551,9 +644,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/vcs" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -570,10 +673,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -589,11 +712,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/deployments/{deploymentId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -620,10 +764,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/download" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -645,10 +809,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/deployments/{deploymentId}/status" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -676,9 +860,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -723,9 +917,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -742,10 +946,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -761,11 +985,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let execution_id = execution_id.into(); + if execution_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"executionId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/executions/{executionId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{executionId}", &execution_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{executionId}", &execution_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -792,9 +1037,19 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -822,9 +1077,19 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables" .to_string() - .replace("{functionId}", &function_id.into().to_string()); + .replace("{functionId}", &function_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -841,10 +1106,30 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -874,10 +1159,30 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -893,11 +1198,32 @@ impl Functions { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let function_id = function_id.into(); + if function_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"functionId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/functions/{functionId}/variables/{variableId}" .to_string() - .replace("{functionId}", &function_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{functionId}", &function_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/messaging.rs b/src/services/messaging.rs index 71dc9c2..596c87a 100644 --- a/src/services/messaging.rs +++ b/src/services/messaging.rs @@ -222,9 +222,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/email/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -433,9 +443,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/push/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -538,9 +558,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/sms/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -556,9 +586,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -571,10 +611,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } let path = "/messaging/messages/{messageId}" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -601,9 +652,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let message_id = message_id.into(); + if message_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"messageId\"", + None, + String::new(), + )); + } + let path = "/messaging/messages/{messageId}/targets" .to_string() - .replace("{messageId}", &message_id.into().to_string()); + .replace("{messageId}", &message_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -724,9 +785,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/apns/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -860,9 +931,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/fcm/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -969,9 +1050,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/mailgun/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1044,9 +1135,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/msg91/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1137,9 +1238,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/resend/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1230,9 +1341,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/sendgrid/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1339,9 +1460,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/ses/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1478,9 +1609,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/smtp/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1553,9 +1694,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/telesign/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1628,9 +1779,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/textmagic/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1703,9 +1864,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/twilio/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1778,9 +1949,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/vonage/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1796,9 +1977,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } + let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1813,10 +2004,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let provider_id = provider_id.into(); + if provider_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"providerId\"", + None, + String::new(), + )); + } let path = "/messaging/providers/{providerId}" .to_string() - .replace("{providerId}", &provider_id.into().to_string()); + .replace("{providerId}", &provider_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1897,9 +2099,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1935,9 +2147,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1949,10 +2171,21 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1983,9 +2216,19 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2006,9 +2249,19 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers" .to_string() - .replace("{topicId}", &topic_id.into().to_string()); + .replace("{topicId}", &topic_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2025,10 +2278,30 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } + let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2044,11 +2317,32 @@ impl Messaging { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let topic_id = topic_id.into(); + if topic_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"topicId\"", + None, + String::new(), + )); + } + + let subscriber_id = subscriber_id.into(); + if subscriber_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"subscriberId\"", + None, + String::new(), + )); + } let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .to_string() - .replace("{topicId}", &topic_id.into().to_string()) - .replace("{subscriberId}", &subscriber_id.into().to_string()); + .replace("{topicId}", &topic_id) + .replace("{subscriberId}", &subscriber_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/mongo.rs b/src/services/mongo.rs index 9b57b1e..8650fdd 100644 --- a/src/services/mongo.rs +++ b/src/services/mongo.rs @@ -121,8 +121,8 @@ impl Mongo { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mongo { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mongo { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mongo { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -682,9 +909,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -707,9 +944,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -735,9 +982,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -768,9 +1025,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -787,9 +1054,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -806,9 +1083,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -841,9 +1128,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -854,6 +1151,18 @@ impl Mongo { /// backup restoration, provide a backupId. For PITR, provide a targetTime as /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and /// is only available for enterprise databases. + /// + /// By default the backup is replayed over the database it was taken from. Pass + /// `restoreMode` as `clone` to recover it onto a second workload beside this + /// database instead: this database keeps serving its own data while the clone + /// is filled, and the switch happens as soon as the clone is ready, on the + /// endpoint and credentials it already had. Pass `autoPromote` as false to + /// hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + /// to recover onto a separate database with its own endpoint, either one you + /// name with `targetDatabaseId` or one provisioned as a copy of this + /// database's engine, version, specification and replicas. Neither mode is + /// available for a point-in-time recovery or an incremental backup. + #[allow(clippy::too_many_arguments)] pub async fn create_restoration( &self, database_id: impl Into, @@ -861,6 +1170,9 @@ impl Mongo { backup_id: Option<&str>, target_database_id: Option<&str>, target_time: Option<&str>, + restore_mode: Option<&str>, + target_name: Option<&str>, + auto_promote: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { @@ -875,13 +1187,32 @@ impl Mongo { if let Some(value) = target_time { params.insert("targetTime".to_string(), json!(value)); } + if let Some(value) = restore_mode { + params.insert("restoreMode".to_string(), json!(value)); + } + if let Some(value) = target_name { + params.insert("targetName".to_string(), json!(value)); + } + if let Some(value) = auto_promote { + params.insert("autoPromote".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -899,16 +1230,82 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) .await } + /// Switch the database over to the clone a restoration recovered. The database + /// keeps + /// its endpoint and credentials; clients reconnect once. Writes made after the + /// recovery point are discarded, and the side being replaced is retained + /// briefly so + /// the switch can be reversed. + pub async fn promote_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + + let path = "/mongo/{databaseId}/restorations/{restorationId}/promotions" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get real-time health and status information for a dedicated database. /// Returns health status, readiness, uptime, connection info, replica status, /// and volume information. @@ -920,9 +1317,19 @@ impl Mongo { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -942,9 +1349,19 @@ impl Mongo { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mongo/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/mysql.rs b/src/services/mysql.rs index 434f42b..ddfe81e 100644 --- a/src/services/mysql.rs +++ b/src/services/mysql.rs @@ -121,8 +121,8 @@ impl Mysql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Mysql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Mysql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Mysql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,6 +896,10 @@ impl Mysql { /// without a per-query cloud round-trip. The statement type must be on the /// database's configured allow-list. Use bound parameters for any /// user-supplied values — the API does not interpolate raw strings. + /// Long-running statements (for example CREATE INDEX) can outlive the HTTP + /// request: if the request ends before a result is returned, check the + /// database before retrying, and prefer a direct connection for work that may + /// take minutes. pub async fn create_execution( &self, database_id: impl Into, @@ -688,9 +919,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -719,9 +960,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -744,9 +995,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -772,9 +1033,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -805,9 +1076,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -824,9 +1105,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -843,9 +1134,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -896,9 +1197,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -915,9 +1226,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -950,9 +1271,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -963,6 +1294,18 @@ impl Mysql { /// backup restoration, provide a backupId. For PITR, provide a targetTime as /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and /// is only available for enterprise databases. + /// + /// By default the backup is replayed over the database it was taken from. Pass + /// `restoreMode` as `clone` to recover it onto a second workload beside this + /// database instead: this database keeps serving its own data while the clone + /// is filled, and the switch happens as soon as the clone is ready, on the + /// endpoint and credentials it already had. Pass `autoPromote` as false to + /// hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + /// to recover onto a separate database with its own endpoint, either one you + /// name with `targetDatabaseId` or one provisioned as a copy of this + /// database's engine, version, specification and replicas. Neither mode is + /// available for a point-in-time recovery or an incremental backup. + #[allow(clippy::too_many_arguments)] pub async fn create_restoration( &self, database_id: impl Into, @@ -970,6 +1313,9 @@ impl Mysql { backup_id: Option<&str>, target_database_id: Option<&str>, target_time: Option<&str>, + restore_mode: Option<&str>, + target_name: Option<&str>, + auto_promote: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { @@ -984,13 +1330,32 @@ impl Mysql { if let Some(value) = target_time { params.insert("targetTime".to_string(), json!(value)); } + if let Some(value) = restore_mode { + params.insert("restoreMode".to_string(), json!(value)); + } + if let Some(value) = target_name { + params.insert("targetName".to_string(), json!(value)); + } + if let Some(value) = auto_promote { + params.insert("autoPromote".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1008,16 +1373,82 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) .await } + /// Switch the database over to the clone a restoration recovered. The database + /// keeps + /// its endpoint and credentials; clients reconnect once. Writes made after the + /// recovery point are discarded, and the side being replaced is retained + /// briefly so + /// the switch can be reversed. + pub async fn promote_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + + let path = "/mysql/{databaseId}/restorations/{restorationId}/promotions" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get real-time health and status information for a dedicated database. /// Returns health status, readiness, uptime, connection info, replica status, /// and volume information. @@ -1029,9 +1460,19 @@ impl Mysql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1051,9 +1492,19 @@ impl Mysql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/mysql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/oauth2.rs b/src/services/oauth2.rs index 834934a..9691f1f 100644 --- a/src/services/oauth2.rs +++ b/src/services/oauth2.rs @@ -81,7 +81,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -120,7 +120,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -165,7 +168,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, request_uri: Option<&str>, ) -> crate::error::Result { @@ -204,7 +207,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -238,7 +244,7 @@ impl Oauth2 { client_id: Option<&str>, scope: Option<&str>, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -252,7 +258,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -318,6 +327,16 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let grant_id = grant_id.into(); + if grant_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"grantId\"", + None, + String::new(), + )); + } + let path = "/oauth2/{project_id}/grants/{grant_id}" .to_string() .replace( @@ -329,7 +348,7 @@ impl Oauth2 { .cloned() .unwrap_or_default(), ) - .replace("{grant_id}", &grant_id.into().to_string()); + .replace("{grant_id}", &grant_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -430,7 +449,7 @@ impl Oauth2 { prompt: Option<&str>, max_age: Option, authorization_details: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -462,7 +481,10 @@ impl Oauth2 { params.insert("authorization_details".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); @@ -603,7 +625,7 @@ impl Oauth2 { client_secret: Option<&str>, code_verifier: Option<&str>, redirect_uri: Option<&str>, - resource: Option<&str>, + resource: Option>, audience: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); @@ -630,7 +652,10 @@ impl Oauth2 { params.insert("redirect_uri".to_string(), json!(value)); } if let Some(value) = resource { - params.insert("resource".to_string(), json!(value)); + params.insert( + "resource".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = audience { params.insert("audience".to_string(), json!(value)); diff --git a/src/services/organization.rs b/src/services/organization.rs index 176b0f5..a574ade 100644 --- a/src/services/organization.rs +++ b/src/services/organization.rs @@ -60,6 +60,7 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/organization".to_string(); @@ -129,9 +130,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -155,9 +166,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/organization/installations/{installationId}" .to_string() - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -170,130 +191,25 @@ impl Organization { pub async fn delete_installation( &self, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}" - .to_string() - .replace("{installationId}", &installation_id.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a list of all API keys from the current organization. - pub async fn list_keys( - &self, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Create a new organization API key. - pub async fn create_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("keyId".to_string(), json!(key_id.into())); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); - } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys".to_string(); - - self.client - .call(Method::POST, &path, Some(api_headers), Some(params)) - .await - } - - /// Get a key by its unique ID. This endpoint returns details about a specific - /// API key in your organization including its scopes. - pub async fn get_key( - &self, - key_id: impl Into, - ) -> crate::error::Result { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) - .await - } - - /// Update a key by its unique ID. Use this endpoint to update the name, - /// scopes, or expiration time of an API key. - pub async fn update_key( - &self, - key_id: impl Into, - name: impl Into, - scopes: Vec, - expire: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - params.insert("name".to_string(), json!(name.into())); - params.insert("scopes".to_string(), json!(scopes)); - if let Some(value) = expire { - params.insert("expire".to_string(), json!(value)); + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}" - .to_string() - .replace("{keyId}", &key_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Delete a key by its unique ID. Once deleted, the key can no longer be used - /// to authenticate API calls. - pub async fn delete_key(&self, key_id: impl Into) -> crate::error::Result<()> { - let params = HashMap::new(); - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - - let path = "/organization/keys/{keyId}" + let path = "/organization/installations/{installationId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -382,9 +298,19 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -406,9 +332,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -425,10 +361,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/organization/memberships/{membershipId}" .to_string() - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -496,13 +443,25 @@ impl Organization { project_id: impl Into, ) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -518,9 +477,19 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } + let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -532,10 +501,21 @@ impl Organization { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let project_id = project_id.into(); + if project_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"projectId\"", + None, + String::new(), + )); + } let path = "/organization/projects/{projectId}" .to_string() - .replace("{projectId}", &project_id.into().to_string()); + .replace("{projectId}", &project_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/postgresql.rs b/src/services/postgresql.rs index e736abe..94d766a 100644 --- a/src/services/postgresql.rs +++ b/src/services/postgresql.rs @@ -121,8 +121,8 @@ impl Postgresql { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -147,9 +147,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -259,9 +269,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -272,18 +292,25 @@ impl Postgresql { /// status will be set to 'deleting' and all resources will be cleaned up. /// Deletion is allowed from any state, and repeating the call re-dispatches /// the cleanup. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -307,9 +334,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +368,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -356,9 +403,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -392,9 +449,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -411,10 +478,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -448,10 +535,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -464,16 +571,36 @@ impl Postgresql { &self, database_id: impl Into, policy_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let policy_id = policy_id.into(); + if policy_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"policyId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{policyId}", &policy_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{policyId}", &policy_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -513,9 +640,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/storage" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -533,10 +670,30 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -549,16 +706,36 @@ impl Postgresql { &self, database_id: impl Into, backup_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let backup_id = backup_id.into(); + if backup_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"backupId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/backups/{backupId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{backupId}", &backup_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{backupId}", &backup_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -575,9 +752,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +793,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -628,10 +825,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let branch_id = branch_id.into(); + if branch_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"branchId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/branches/{branchId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{branchId}", &branch_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{branchId}", &branch_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -651,9 +868,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/credentials" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,6 +896,10 @@ impl Postgresql { /// without a per-query cloud round-trip. The statement type must be on the /// database's configured allow-list. Use bound parameters for any /// user-supplied values — the API does not interpolate raw strings. + /// Long-running statements (for example CREATE INDEX) can outlive the HTTP + /// request: if the request ends before a result is returned, check the + /// database before retrying, and prefer a direct connection for work that may + /// take minutes. pub async fn create_execution( &self, database_id: impl Into, @@ -688,9 +919,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/executions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -706,9 +947,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -728,9 +979,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -749,10 +1010,30 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let extension_name = extension_name.into(); + if extension_name.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"extensionName\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/extensions/{extensionName}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{extensionName}", &extension_name.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{extensionName}", &extension_name); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -781,9 +1062,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -806,9 +1097,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/maintenance" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -834,9 +1135,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -867,9 +1178,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -886,9 +1207,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pitr" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -905,9 +1236,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -958,9 +1299,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/pooler" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -977,9 +1328,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1012,9 +1373,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1025,6 +1396,18 @@ impl Postgresql { /// backup restoration, provide a backupId. For PITR, provide a targetTime as /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and /// is only available for enterprise databases. + /// + /// By default the backup is replayed over the database it was taken from. Pass + /// `restoreMode` as `clone` to recover it onto a second workload beside this + /// database instead: this database keeps serving its own data while the clone + /// is filled, and the switch happens as soon as the clone is ready, on the + /// endpoint and credentials it already had. Pass `autoPromote` as false to + /// hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + /// to recover onto a separate database with its own endpoint, either one you + /// name with `targetDatabaseId` or one provisioned as a copy of this + /// database's engine, version, specification and replicas. Neither mode is + /// available for a point-in-time recovery or an incremental backup. + #[allow(clippy::too_many_arguments)] pub async fn create_restoration( &self, database_id: impl Into, @@ -1032,6 +1415,9 @@ impl Postgresql { backup_id: Option<&str>, target_database_id: Option<&str>, target_time: Option<&str>, + restore_mode: Option<&str>, + target_name: Option<&str>, + auto_promote: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { @@ -1046,13 +1432,32 @@ impl Postgresql { if let Some(value) = target_time { params.insert("targetTime".to_string(), json!(value)); } + if let Some(value) = restore_mode { + params.insert("restoreMode".to_string(), json!(value)); + } + if let Some(value) = target_name { + params.insert("targetName".to_string(), json!(value)); + } + if let Some(value) = auto_promote { + params.insert("autoPromote".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1070,16 +1475,82 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/restorations/{restorationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{restorationId}", &restoration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) .await } + /// Switch the database over to the clone a restoration recovered. The database + /// keeps + /// its endpoint and credentials; clients reconnect once. Writes made after the + /// recovery point are discarded, and the side being replaced is retained + /// briefly so + /// the switch can be reversed. + pub async fn promote_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let restoration_id = restoration_id.into(); + if restoration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"restorationId\"", + None, + String::new(), + )); + } + + let path = "/postgresql/{databaseId}/restorations/{restorationId}/promotions" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{restorationId}", &restoration_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get real-time health and status information for a dedicated database. /// Returns health status, readiness, uptime, connection info, replica status, /// and volume information. @@ -1091,9 +1562,19 @@ impl Postgresql { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1113,9 +1594,19 @@ impl Postgresql { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/postgresql/{databaseId}/upgrades" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) diff --git a/src/services/presences.rs b/src/services/presences.rs index 2954c14..6b777c6 100644 --- a/src/services/presences.rs +++ b/src/services/presences.rs @@ -64,9 +64,19 @@ impl Presences { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -102,9 +112,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -148,9 +168,19 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } + let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -162,10 +192,21 @@ impl Presences { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let presence_id = presence_id.into(); + if presence_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"presenceId\"", + None, + String::new(), + )); + } let path = "/presences/{presenceId}" .to_string() - .replace("{presenceId}", &presence_id.into().to_string()); + .replace("{presenceId}", &presence_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/project.rs b/src/services/project.rs index 43c2af2..24f9252 100644 --- a/src/services/project.rs +++ b/src/services/project.rs @@ -27,11 +27,13 @@ impl Project { /// Get a project. pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); self.client - .call(Method::GET, &path, None, Some(params)) + .call(Method::GET, &path, Some(api_headers), Some(params)) .await } @@ -40,6 +42,7 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project".to_string(); @@ -266,9 +269,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -294,9 +307,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } + let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -309,10 +332,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let key_id = key_id.into(); + if key_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"keyId\"", + None, + String::new(), + )); + } let path = "/project/keys/{keyId}" .to_string() - .replace("{keyId}", &key_id.into().to_string()); + .replace("{keyId}", &key_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -402,9 +436,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -424,9 +468,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } + let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -439,10 +493,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let number = number.into(); + if number.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"number\"", + None, + String::new(), + )); + } let path = "/project/mock-phones/{number}" .to_string() - .replace("{number}", &number.into().to_string()); + .replace("{number}", &number); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1253,8 +1318,8 @@ impl Project { &self, client_id: Option<&str>, client_secret: Option<&str>, - prompt: Option>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1263,12 +1328,12 @@ impl Project { if let Some(value) = client_secret { params.insert("clientSecret".to_string(), json!(value)); } - if let Some(value) = prompt { - params.insert("prompt".to_string(), json!(value)); - } if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } + if let Some(value) = prompt { + params.insert("prompt".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); @@ -2147,7 +2212,7 @@ impl Project { } /// 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. pub async fn update_android_platform( &self, platform_id: impl Into, @@ -2168,9 +2233,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/android/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2222,9 +2297,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/apple/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2270,9 +2355,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/linux/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2318,9 +2413,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/web/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2372,9 +2477,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/windows/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2391,9 +2506,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } + let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2409,10 +2534,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let platform_id = platform_id.into(); + if platform_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"platformId\"", + None, + String::new(), + )); + } let path = "/project/platforms/{platformId}" .to_string() - .replace("{platformId}", &platform_id.into().to_string()); + .replace("{platformId}", &platform_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -3027,6 +3163,7 @@ impl Project { ); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/project/smtp/tests".to_string(); @@ -3197,9 +3334,19 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -3228,9 +3375,19 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -3245,10 +3402,21 @@ impl Project { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/project/variables/{variableId}" .to_string() - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/proxy.rs b/src/services/proxy.rs index 2507b73..46dcbbf 100644 --- a/src/services/proxy.rs +++ b/src/services/proxy.rs @@ -29,6 +29,8 @@ impl Proxy { /// /// 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. pub async fn create_invalidation( &self, domain: impl Into, @@ -184,6 +186,31 @@ impl Proxy { .await } + /// Create an SMTP ingress rule that asynchronously executes an Appwrite + /// Function for incoming email. + pub async fn create_smtp_rule( + &self, + domain: impl Into, + function_id: impl Into, + branch: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("domain".to_string(), json!(domain.into())); + params.insert("functionId".to_string(), json!(function_id.into())); + if let Some(value) = branch { + params.insert("branch".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/proxy/rules/smtp".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// Get a proxy rule by its unique ID. pub async fn get_rule( &self, @@ -193,9 +220,19 @@ impl Proxy { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -207,10 +244,21 @@ impl Proxy { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } let path = "/proxy/rules/{ruleId}" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -230,9 +278,19 @@ impl Proxy { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let rule_id = rule_id.into(); + if rule_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"ruleId\"", + None, + String::new(), + )); + } + let path = "/proxy/rules/{ruleId}/status" .to_string() - .replace("{ruleId}", &rule_id.into().to_string()); + .replace("{ruleId}", &rule_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/sites.rs b/src/services/sites.rs index 150a50d..99a6e87 100644 --- a/src/services/sites.rs +++ b/src/services/sites.rs @@ -217,9 +217,17 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -331,9 +339,17 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -345,10 +361,19 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}" - .to_string() - .replace("{siteId}", &site_id.into().to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -368,9 +393,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployment" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -402,9 +437,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -443,12 +488,30 @@ impl Sites { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client - .file_upload(&path, Some(api_headers), params, "code", code, None) + .upload( + Method::POST, + &path, + Some(api_headers), + params, + "code", + code, + None, + ) .await } @@ -468,9 +531,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/duplicate" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -506,9 +579,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/template" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -535,9 +618,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/vcs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -554,10 +647,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -573,11 +686,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/deployments/{deploymentId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -604,10 +738,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/download" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -629,10 +783,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let deployment_id = deployment_id.into(); + if deployment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"deploymentId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/deployments/{deploymentId}/status" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{deploymentId}", &deployment_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{deploymentId}", &deployment_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -660,9 +834,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -679,10 +863,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -694,16 +898,36 @@ impl Sites { &self, site_id: impl Into, log_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let log_id = log_id.into(); + if log_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"logId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/logs/{logId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{logId}", &log_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{logId}", &log_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -730,9 +954,19 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -760,9 +994,19 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables" .to_string() - .replace("{siteId}", &site_id.into().to_string()); + .replace("{siteId}", &site_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -779,10 +1023,30 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -812,10 +1076,30 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } + let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -831,11 +1115,32 @@ impl Sites { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let site_id = site_id.into(); + if site_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"siteId\"", + None, + String::new(), + )); + } + + let variable_id = variable_id.into(); + if variable_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"variableId\"", + None, + String::new(), + )); + } let path = "/sites/{siteId}/variables/{variableId}" .to_string() - .replace("{siteId}", &site_id.into().to_string()) - .replace("{variableId}", &variable_id.into().to_string()); + .replace("{siteId}", &site_id) + .replace("{variableId}", &variable_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/storage.rs b/src/services/storage.rs index 4736eaf..2f49674 100644 --- a/src/services/storage.rs +++ b/src/services/storage.rs @@ -127,9 +127,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -191,9 +201,19 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -205,10 +225,21 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -240,9 +271,19 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -293,12 +334,23 @@ impl Storage { ); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()); + .replace("{bucketId}", &bucket_id); self.client - .file_upload( + .upload( + Method::POST, &path, Some(api_headers), params, @@ -320,10 +372,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -353,10 +425,30 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -373,11 +465,32 @@ impl Storage { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } let path = "/storage/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -400,10 +513,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/download" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -473,10 +606,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/preview" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/storage/buckets/{bucketId}/files/{fileId}/view" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/tables_db.rs b/src/services/tables_db.rs index a9f0f21..0807051 100644 --- a/src/services/tables_db.rs +++ b/src/services/tables_db.rs @@ -92,8 +92,8 @@ impl TablesDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -163,9 +163,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -190,9 +200,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -207,10 +227,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/tablesdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -231,9 +262,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -250,9 +291,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -289,9 +340,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -304,10 +365,21 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -336,9 +408,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -355,9 +437,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -365,8 +457,13 @@ impl TablesDB { } /// Start migrating a serverless TablesDB database onto a dedicated MySQL - /// compute. Data is copied to the target while the source stays live, with a - /// brief read-only window during cutover. + /// compute. Data is copied to the target while the source stays live. Reads + /// continue throughout. Row writes are held for up to a few seconds while + /// routing switches to the dedicated compute; a write the switch has not + /// absorbed within that hold is refused with `database_migration_cutover` and + /// can be retried. Schema changes (tables, columns, indexes) are refused from + /// creation until the cutover completes, and resume once the migration is + /// `soaking`. pub async fn create_migration( &self, database_id: impl Into, @@ -382,9 +479,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -401,10 +508,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -417,16 +544,36 @@ impl TablesDB { &self, database_id: impl Into, migration_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -436,9 +583,12 @@ impl TablesDB { /// Cut a verified TablesDB migration over to its dedicated compute. Only /// applies to a migration created with `autoCutover` disabled, which waits at /// `ready_to_cutover` until this is called. The routing flip happens shortly - /// after this returns, with a brief read-only window. One call buys one - /// attempt: a cutover that fails a check returns the migration to `verifying` - /// and parks it again, so call this once more to retry. + /// after this returns. Reads are unaffected; row writes are held for up to a + /// few seconds while it lands, and a write the flip has not absorbed within + /// that hold is refused with `database_migration_cutover` and can be retried. + /// One call buys one attempt: a cutover that fails a check returns the + /// migration to `verifying` and parks it again, so call this once more to + /// retry. pub async fn create_cutover( &self, database_id: impl Into, @@ -449,10 +599,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let migration_id = migration_id.into(); + if migration_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"migrationId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/migrations/{migrationId}/cutovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{migrationId}", &migration_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{migrationId}", &migration_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -483,9 +653,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -502,9 +682,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -522,9 +712,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -556,9 +756,19 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -606,9 +816,19 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -626,10 +846,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -671,10 +911,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -691,11 +951,32 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -723,10 +1004,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -766,10 +1067,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -808,11 +1129,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -842,10 +1193,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -875,11 +1246,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -909,10 +1310,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -942,11 +1363,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -976,10 +1427,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1009,11 +1480,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1053,10 +1554,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1095,11 +1616,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1139,10 +1690,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1181,11 +1752,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1225,10 +1826,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1267,11 +1888,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1301,10 +1952,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1334,11 +2005,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1364,10 +2065,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1397,11 +2118,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1436,10 +2187,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1469,11 +2240,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1508,10 +2309,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1541,11 +2362,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1571,10 +2422,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1604,11 +2475,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1634,10 +2535,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1667,11 +2588,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1711,16 +2662,98 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) .await } + /// Update relationship column. [Learn more about relationship + /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + pub async fn update_relationship_column( + &self, + database_id: impl Into, + table_id: impl Into, + key: impl Into, + on_delete: Option, + new_key: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = on_delete { + params.insert("onDelete".to_string(), json!(value)); + } + if let Some(value) = new_key { + params.insert("newKey".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}" + .to_string() + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Create a string column. #[allow(clippy::too_many_arguments)] pub async fn create_string_column( @@ -1751,10 +2784,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1789,11 +2842,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1828,10 +2911,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1861,11 +2964,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1895,10 +3028,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1928,11 +3081,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1969,10 +3152,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2007,11 +3210,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2029,11 +3262,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2050,47 +3313,46 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" - .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); - - self.client - .call(Method::DELETE, &path, Some(api_headers), Some(params)) - .await - } + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } - /// Update relationship column. [Learn more about relationship - /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - pub async fn update_relationship_column( - &self, - database_id: impl Into, - table_id: impl Into, - key: impl Into, - on_delete: Option, - new_key: Option<&str>, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = on_delete { - params.insert("onDelete".to_string(), json!(value)); + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); } - if let Some(value) = new_key { - params.insert("newKey".to_string(), json!(value)); + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "application/json".to_string()); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship" + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client - .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } @@ -2115,10 +3377,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2127,7 +3409,9 @@ impl TablesDB { /// Creates an index on the columns listed. Your index should include all the /// columns you will query in a single request. - /// Type can be `key`, `fulltext`, or `unique`. + /// Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + /// is only available on PostgreSQL and lets `contains`, `startsWith`, and + /// `endsWith` queries on string columns use an index. #[allow(clippy::too_many_arguments)] pub async fn create_index( &self, @@ -2159,10 +3443,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2180,11 +3484,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2201,12 +3535,43 @@ impl TablesDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2243,10 +3608,30 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2282,10 +3667,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2312,10 +3717,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -2342,10 +3767,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2379,10 +3824,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2412,10 +3877,30 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2445,11 +3930,41 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -2486,11 +4001,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -2525,11 +4070,41 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2550,12 +4125,43 @@ impl TablesDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -2588,12 +4194,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -2626,12 +4272,52 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let table_id = table_id.into(); + if table_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tableId\"", + None, + String::new(), + )); + } + + let row_id = row_id.into(); + if row_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"rowId\"", + None, + String::new(), + )); + } + + let column = column.into(); + if column.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"column\"", + None, + String::new(), + )); + } + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{tableId}", &table_id.into().to_string()) - .replace("{rowId}", &row_id.into().to_string()) - .replace("{column}", &column.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{tableId}", &table_id) + .replace("{rowId}", &row_id) + .replace("{column}", &column); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/teams.rs b/src/services/teams.rs index 5f55c5b..68d6978 100644 --- a/src/services/teams.rs +++ b/src/services/teams.rs @@ -93,9 +93,17 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -114,9 +122,17 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -129,10 +145,19 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}" - .to_string() - .replace("{teamId}", &team_id.into().to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -159,9 +184,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -187,9 +222,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -207,10 +252,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -235,10 +300,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -252,16 +337,36 @@ impl Teams { &self, team_id: impl Into, installation_id: impl Into, - ) -> crate::error::Result { + ) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let installation_id = installation_id.into(); + if installation_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"installationId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/installations/{installationId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{installationId}", &installation_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{installationId}", &installation_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -294,9 +399,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -362,9 +477,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -383,10 +508,30 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -411,10 +556,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -432,11 +597,32 @@ impl Teams { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } let path = "/teams/{teamId}/memberships/{membershipId}" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -463,10 +649,30 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + + let membership_id = membership_id.into(); + if membership_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"membershipId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/memberships/{membershipId}/status" .to_string() - .replace("{teamId}", &team_id.into().to_string()) - .replace("{membershipId}", &membership_id.into().to_string()); + .replace("{teamId}", &team_id) + .replace("{membershipId}", &membership_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -484,9 +690,19 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -507,9 +723,19 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let team_id = team_id.into(); + if team_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"teamId\"", + None, + String::new(), + )); + } + let path = "/teams/{teamId}/prefs" .to_string() - .replace("{teamId}", &team_id.into().to_string()); + .replace("{teamId}", &team_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) diff --git a/src/services/tokens.rs b/src/services/tokens.rs index 43b9063..d58c5cb 100644 --- a/src/services/tokens.rs +++ b/src/services/tokens.rs @@ -46,10 +46,30 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -72,10 +92,30 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let bucket_id = bucket_id.into(); + if bucket_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"bucketId\"", + None, + String::new(), + )); + } + + let file_id = file_id.into(); + if file_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"fileId\"", + None, + String::new(), + )); + } + let path = "/tokens/buckets/{bucketId}/files/{fileId}" .to_string() - .replace("{bucketId}", &bucket_id.into().to_string()) - .replace("{fileId}", &file_id.into().to_string()); + .replace("{bucketId}", &bucket_id) + .replace("{fileId}", &file_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -91,9 +131,19 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -115,9 +165,19 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } + let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -129,10 +189,21 @@ impl Tokens { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let token_id = token_id.into(); + if token_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"tokenId\"", + None, + String::new(), + )); + } let path = "/tokens/{tokenId}" .to_string() - .replace("{tokenId}", &token_id.into().to_string()); + .replace("{tokenId}", &token_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) diff --git a/src/services/users.rs b/src/services/users.rs index 7cd8e38..73b7d8b 100644 --- a/src/services/users.rs +++ b/src/services/users.rs @@ -184,10 +184,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let identity_id = identity_id.into(); + if identity_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"identityId\"", + None, + String::new(), + )); + } let path = "/users/identities/{identityId}" .to_string() - .replace("{identityId}", &identity_id.into().to_string()); + .replace("{identityId}", &identity_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -377,9 +388,17 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -396,10 +415,19 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}" - .to_string() - .replace("{userId}", &user_id.into().to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let path = "/users/{userId}".to_string().replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -418,9 +446,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/email" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -431,7 +469,10 @@ impl Users { /// 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. pub async fn update_impersonator( &self, user_id: impl Into, @@ -443,9 +484,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/impersonator" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -472,9 +523,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/jwts" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -504,41 +565,22 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/labels" - .to_string() - .replace("{userId}", &user_id.into().to_string()); - - self.client - .call(Method::PUT, &path, Some(api_headers), Some(params)) - .await - } - - /// Get the user activity logs list by its unique ID. - pub async fn list_logs( - &self, - user_id: impl Into, - queries: Option>, - total: Option, - ) -> crate::error::Result { - let mut params = HashMap::new(); - if let Some(value) = queries { - params.insert( - "queries".to_string(), - json!(value.into_iter().map(|s| s.into()).collect::>()), - ); - } - if let Some(value) = total { - params.insert("total".to_string(), json!(value)); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); } - let mut api_headers = HashMap::new(); - api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/logs" + let path = "/users/{userId}/labels" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client - .call(Method::GET, &path, Some(api_headers), Some(params)) + .call(Method::PUT, &path, Some(api_headers), Some(params)) .await } @@ -566,9 +608,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/memberships" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -587,9 +639,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -605,10 +667,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/mfa/authenticators/{type}" .to_string() - .replace("{userId}", &user_id.into().to_string()) + .replace("{userId}", &user_id) .replace("{type}", &r#type.to_string()); self.client @@ -627,10 +700,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let challenge_id = challenge_id.into(); + if challenge_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"challengeId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/challenges/{challengeId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{challengeId}", &challenge_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{challengeId}", &challenge_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -646,9 +739,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/factors" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -667,9 +770,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -689,9 +802,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -711,9 +834,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/mfa/recovery-codes" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -732,9 +865,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/name" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -917,9 +1060,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/password" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -938,9 +1091,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -956,9 +1119,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -979,9 +1152,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/prefs" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1001,9 +1184,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1025,9 +1218,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1039,10 +1242,21 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1058,11 +1272,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let session_id = session_id.into(); + if session_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"sessionId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/sessions/{sessionId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{sessionId}", &session_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{sessionId}", &session_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1082,9 +1317,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/status" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1111,9 +1356,19 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1144,9 +1399,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1163,10 +1428,30 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1196,10 +1481,30 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1215,11 +1520,32 @@ impl Users { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + + let target_id = target_id.into(); + if target_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"targetId\"", + None, + String::new(), + )); + } let path = "/users/{userId}/targets/{targetId}" .to_string() - .replace("{userId}", &user_id.into().to_string()) - .replace("{targetId}", &target_id.into().to_string()); + .replace("{userId}", &user_id) + .replace("{targetId}", &target_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1247,9 +1573,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/tokens" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1268,9 +1604,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -1289,9 +1635,19 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let user_id = user_id.into(); + if user_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"userId\"", + None, + String::new(), + )); + } + let path = "/users/{userId}/verification/phone" .to_string() - .replace("{userId}", &user_id.into().to_string()); + .replace("{userId}", &user_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/services/vectors_db.rs b/src/services/vectors_db.rs index be3894b..a89bf38 100644 --- a/src/services/vectors_db.rs +++ b/src/services/vectors_db.rs @@ -86,8 +86,8 @@ impl VectorsDB { } /// 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. pub async fn list_specifications( &self, ) -> crate::error::Result { @@ -157,9 +157,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -184,9 +194,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -201,10 +221,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/transactions/{transactionId}" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -225,9 +256,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let transaction_id = transaction_id.into(); + if transaction_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"transactionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/transactions/{transactionId}/operations" .to_string() - .replace("{transactionId}", &transaction_id.into().to_string()); + .replace("{transactionId}", &transaction_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -244,9 +285,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -281,9 +332,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -296,10 +357,21 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -331,9 +403,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -375,9 +457,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -395,10 +487,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -438,10 +550,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -458,11 +590,32 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -499,10 +652,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -538,10 +711,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -568,10 +761,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -598,10 +811,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -636,10 +869,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -669,10 +922,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -712,10 +985,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/query" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -745,11 +1038,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -786,11 +1109,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -825,11 +1178,41 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) @@ -850,12 +1233,43 @@ impl VectorsDB { } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let document_id = document_id.into(); + if document_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"documentId\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{documentId}", &document_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{documentId}", &document_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -883,10 +1297,30 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -927,10 +1361,30 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -948,11 +1402,41 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -969,12 +1453,43 @@ impl VectorsDB { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + + let collection_id = collection_id.into(); + if collection_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"collectionId\"", + None, + String::new(), + )); + } + + let key = key.into(); + if key.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"key\"", + None, + String::new(), + )); + } let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" .to_string() - .replace("{databaseId}", &database_id.into().to_string()) - .replace("{collectionId}", &collection_id.into().to_string()) - .replace("{key}", &key.into().to_string()); + .replace("{databaseId}", &database_id) + .replace("{collectionId}", &collection_id) + .replace("{key}", &key); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -1003,9 +1518,19 @@ impl VectorsDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/failovers" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::POST, &path, Some(api_headers), Some(params)) @@ -1036,9 +1561,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/operations" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1055,9 +1590,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/replicas" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -1075,9 +1620,19 @@ impl VectorsDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let database_id = database_id.into(); + if database_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"databaseId\"", + None, + String::new(), + )); + } + let path = "/vectorsdb/{databaseId}/status" .to_string() - .replace("{databaseId}", &database_id.into().to_string()); + .replace("{databaseId}", &database_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) diff --git a/src/services/webhooks.rs b/src/services/webhooks.rs index 0e3e171..c53feda 100644 --- a/src/services/webhooks.rs +++ b/src/services/webhooks.rs @@ -112,9 +112,19 @@ impl Webhooks { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::GET, &path, Some(api_headers), Some(params)) @@ -161,9 +171,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PUT, &path, Some(api_headers), Some(params)) @@ -176,10 +196,21 @@ impl Webhooks { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } let path = "/webhooks/{webhookId}" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::DELETE, &path, Some(api_headers), Some(params)) @@ -202,9 +233,19 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); + let webhook_id = webhook_id.into(); + if webhook_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"webhookId\"", + None, + String::new(), + )); + } + let path = "/webhooks/{webhookId}/secret" .to_string() - .replace("{webhookId}", &webhook_id.into().to_string()); + .replace("{webhookId}", &webhook_id); self.client .call(Method::PATCH, &path, Some(api_headers), Some(params)) diff --git a/src/topic.rs b/src/topic.rs new file mode 100644 index 0000000..30c26fc --- /dev/null +++ b/src/topic.rs @@ -0,0 +1,158 @@ +//! Topic builder for Appwrite Push, level by level. +//! +//! ``` +//! use appwrite::topic; +//! +//! # fn main() -> Result<(), topic::TopicError> { +//! assert_eq!(topic::path(&["user", "123", "notification"])?.to_string(), "user/123/notification"); +//! assert_eq!(topic::path(&["org", "42"])?.path(&["logs"])?.to_string(), "org/42/logs"); +//! # Ok(()) +//! # } +//! ``` + +use std::fmt; + +/// Error returned by [`path`] and [`Topic::path`] for invalid levels. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct TopicError { + message: String, +} + +impl TopicError { + fn new(message: impl Into) -> Self { + Self { + message: message.into(), + } + } + + /// The error message + pub fn message(&self) -> &str { + &self.message + } +} + +impl fmt::Display for TopicError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.message) + } +} + +impl std::error::Error for TopicError {} + +/// A topic being built. Start one with [`path`]. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Topic { + levels: Vec, +} + +/// Start a topic with the given levels, e.g. `topic::path(&["user", user_id])`. +pub fn path>(levels: &[S]) -> Result { + Ok(Topic { + levels: levels_of(levels)?, + }) +} + +impl Topic { + /// Append the given levels. + pub fn path>(mut self, levels: &[S]) -> Result { + self.levels.extend(levels_of(levels)?); + Ok(self) + } +} + +impl fmt::Display for Topic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&self.levels.join("/")) + } +} + +/// Validate the levels passed to `path()`: a non-empty list of non-empty strings, none holding +/// the level separator `/` or the MQTT wildcards `+` and `#`. +fn levels_of>(levels: &[S]) -> Result, TopicError> { + if levels.is_empty() { + return Err(TopicError::new("path() needs at least one level")); + } + levels + .iter() + .enumerate() + .map(|(index, level)| { + let level = level.as_ref(); + if level.is_empty() { + return Err(TopicError::new(format!("empty level at index {}", index))); + } + if level.contains('/') { + let parts = level + .split('/') + .map(|part| format!("'{}'", part)) + .collect::>() + .join(", "); + return Err(TopicError::new(format!( + "\"{}\" contains \"/\", split it: path([{}])", + level, parts + ))); + } + if level.contains('+') { + return Err(TopicError::new(format!( + "\"{}\" contains \"+\", not allowed in a topic", + level + ))); + } + if level.contains('#') { + return Err(TopicError::new(format!( + "\"{}\" contains \"#\", not allowed in a topic", + level + ))); + } + if level.contains('\0') { + return Err(TopicError::new(format!( + "level at index {} contains a NUL character", + index + ))); + } + Ok(level.to_string()) + }) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_paths() { + assert_eq!( + path(&["user", "123", "notification"]).unwrap().to_string(), + "user/123/notification" + ); + assert_eq!( + path(&["org", "42", "user", "123"]) + .unwrap() + .path(&["notification"]) + .unwrap() + .to_string(), + "org/42/user/123/notification" + ); + assert_eq!( + path(&[String::from("user"), String::from("123")]) + .unwrap() + .to_string(), + "user/123" + ); + } + + #[test] + fn test_errors() { + let invalid: [&[&str]; 7] = [ + &[], + &["user", ""], + &["user/123"], + &["user", "+"], + &["user", "a+b"], + &["user", "#"], + &["user", "a#b"], + ]; + for levels in invalid { + assert!(path(levels).is_err(), "{:?}", levels); + } + } +} diff --git a/tests/tests.rs b/tests/tests.rs index 2821bc3..afdc35f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,11 +1,13 @@ use appwrite::{ Client, + enums::PresetQuality, id::ID, input_file::InputFile, operator::{self, Condition}, permission::Permission, query::Query, role::Role, + topic, services::*, }; use serde_json::json; @@ -112,12 +114,50 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re Err(e) => eprintln!("general.redirected => error {}", e), } + for (id, plain) in [("", "0"), ("0", "")] { + let error = general.validate_path(plain, Some(id)).await.unwrap_err(); + assert_eq!(error.code, 0); + println!("{}", error.message); + } + println!("{}", general.validate_path("0", Some("0")).await?.result); + println!("{}", general.validate_path("0", None).await?.result); + + let zone: String = Plaintext::new(&client).get_zone().await?; + println!("{}", zone); + println!("{}", general.get_mixed().await?.result); + let plaintext = Plaintext::new(&client); + let records = "www 3600 IN A 192.0.2.1"; + println!("{}", plaintext.import_zone(records, None).await?); + let zone_file = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", plaintext.import_zone(records, Some(zone_file)).await?); + + let message = "conversation without a required file"; + println!("{}", general.optional_upload(message, None, None).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), None).await?.result); + println!("{}", general.optional_upload(message, None, Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + let attachment = InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?; + println!("{}", general.optional_upload(message, Some(attachment), Some(json!({ "source": "sdk", "uri": "café" }))).await?.result); + test_general_upload(client, string_in_array).await?; test_large_upload(client, string_in_array).await?; + // A PUT upload has no chunked form, so it must go in one request even with tiny chunks. + let small_chunks = client.set_chunk_size(1024); + let profile = General::new(&small_chunks).upload_generic(InputFile::from_path(Path::new("/app/tests/resources/file.png"), None).await?).await?; + println!("{}", profile.prefs().get::("result").unwrap_or_default()); // Extended General Responses test_general_download(client).await?; + let preset = general.get_preset(None).await?; + println!("preset: name={}, count={}, enabled={}", preset.name, preset.count, preset.enabled); + for item in general.list_presets().await?.presets { + println!("preset: name={}, count={}, enabled={}", item.name, item.count, item.enabled); + } + println!("empty presets: {}", general.list_empty_presets().await?.presets.len()); + println!("preset verified: {}", preset.verified.map_or("null".to_string(), |verified| verified.to_string())); + println!("preset quality default: {}", PresetQuality::default()); + // Exception Responses match general.error400().await { Ok(_) => {}, @@ -145,16 +185,17 @@ async fn test_general_service(client: &Client, string_in_array: &[String]) -> Re println!("Invalid endpoint URL: htp://cloud.appwrite.io/v1"); - let _ = general.empty().await; + let (): () = general.empty().await?; // Test Queries - test_queries(); + test_queries(client).await?; // Test Permission Helpers test_permission_helpers(); // Test Id Helpers test_id_helpers(); + test_topic_helpers(); // Test Operator Helpers test_operator_helpers(); @@ -218,7 +259,7 @@ async fn test_large_upload(client: &Client, string_in_array: &[String]) -> Resul Ok(()) } -fn test_queries() { +async fn test_queries(client: &Client) -> Result<(), Box> { println!("{}", Query::equal("released", true)); println!("{}", Query::equal("title", vec!["Spiderman", "Dr. Strange"])); println!("{}", Query::not_equal("title", "Spiderman")); @@ -293,6 +334,50 @@ fn test_queries() { Query::equal("name", "Alice").to_string(), Query::greater_than("age", 18).to_string(), ])); + println!("{}", Query::relationship("comments", vec![ + Query::equal("approved", true).to_string(), + Query::limit(2).to_string(), + ])); + let general = General::new(client); + let mut queries: Vec = vec![ + Query::count("*", "total").to_string(), + Query::join("orders", "$id", "customerId", "=", "").to_string(), + Query::group_by(vec!["status"]).to_string(), + Query::distinct().to_string(), + Query::covers("location", json!([1, 2])).to_string(), + Query::count_distinct("year", "uniqueYears").to_string(), + Query::sum("price", "total").to_string(), + Query::avg("price", "avgPrice").to_string(), + Query::min("price", "lowest").to_string(), + Query::max("price", "highest").to_string(), + Query::stddev("price", "sd").to_string(), + Query::stddev_pop("price", "sdp").to_string(), + Query::stddev_samp("price", "sds").to_string(), + Query::variance("price", "var").to_string(), + Query::var_pop("price", "vp").to_string(), + Query::var_samp("price", "vs").to_string(), + Query::bit_and("flags", "band").to_string(), + Query::bit_or("flags", "bor").to_string(), + Query::bit_xor("flags", "bxor").to_string(), + Query::having(vec![Query::greater_than("total", 1).to_string()]).to_string(), + Query::left_join("orders", "$id", "customerId", "=", "ord").to_string(), + Query::right_join("orders", "$id", "customerId", "=", "").to_string(), + Query::full_outer_join("orders", "$id", "customerId", "=", "").to_string(), + Query::cross_join("orders", "ord").to_string(), + Query::on("$id", "customerId", "=").to_string(), + Query::left_join_on("orders", "ord", vec![ + Query::on("$id", "customerId", "=").to_string(), + Query::equal("ord.status", "paid").to_string(), + ]).to_string(), + Query::not_covers("location", json!([1, 2])).to_string(), + Query::spatial_equals("location", json!([1, 2])).to_string(), + Query::not_spatial_equals("location", json!([1, 2])).to_string(), + ]; + queries.extend(Query::page(2, 10).iter().map(|query| query.to_string())); + queries.extend(Query::builder().limit(1).build()); + println!("{}", general.list_rows(Some(queries)).await?.result); + + Ok(()) } fn test_permission_helpers() { @@ -313,6 +398,25 @@ fn test_id_helpers() { println!("{}", ID::custom("custom_id")); } +fn test_topic_helpers() { + println!("{}", topic::path(&["user", "123", "notification"]).unwrap()); + println!("{}", topic::path(&["org", "42", "user", "123"]).unwrap().path(&["notification"]).unwrap()); + let cases: Vec<(&str, Vec<&str>)> = vec![ + ("empty path", vec![]), + ("empty level", vec!["user", ""]), + ("slash", vec!["user/123"]), + ("plus", vec!["user", "a+b"]), + ("hash", vec!["user", "#"]), + ("nul", vec!["user", "a\0b"]), + ]; + for (name, levels) in cases { + match topic::path(&levels) { + Ok(_) => println!("Topic {}:failed", name), + Err(_) => println!("Topic {}:passed", name), + } + } +} + fn test_operator_helpers() { println!("{}", operator::increment()); println!("{}", operator::increment_with_max(5, 100));