From dff4ceefc3f5d12856e16f8e5f16cfb71adf364e Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 12:33:40 +0100 Subject: [PATCH 1/2] feat: Rust SDK update for version 0.19.0 --- Cargo.toml | 2 +- README.md | 2 +- .../account/create-email-password-session.md | 3 +- .../account/create-email-verification-otp.md | 22 + .../account/create-id-token-session.md | 27 + docs/examples/account/create-recovery-otp.md | 23 + docs/examples/account/delete-sessions.md | 4 +- docs/examples/account/list-sessions.md | 4 +- .../account/update-email-verification-otp.md | 23 + docs/examples/account/update-recovery-otp.md | 24 + docs/examples/avatars/delete-photo.md | 18 + docs/examples/avatars/update-photo.md | 25 + docs/examples/databases/list-transactions.md | 3 +- .../examples/documentsdb/list-transactions.md | 3 +- .../domains/create-preset-google-workspace.md | 22 + .../examples/domains/create-preset-i-cloud.md | 22 + .../examples/domains/create-preset-mailgun.md | 22 + .../examples/domains/create-preset-outlook.md | 22 + .../domains/create-preset-proton-mail.md | 22 + docs/examples/domains/create-preset-zoho.md | 22 + docs/examples/domains/create-record-a.md | 26 + docs/examples/domains/create-record-aaaa.md | 26 + docs/examples/domains/create-record-alias.md | 26 + docs/examples/domains/create-record-caa.md | 26 + docs/examples/domains/create-record-cname.md | 26 + docs/examples/domains/create-record-https.md | 26 + docs/examples/domains/create-record-mx.md | 27 + docs/examples/domains/create-record-ns.md | 26 + docs/examples/domains/create-record-srv.md | 29 + docs/examples/domains/create-record-txt.md | 26 + docs/examples/domains/create.md | 23 + docs/examples/domains/delete-record.md | 21 + docs/examples/domains/delete.md | 20 + .../domains/get-preset-google-workspace.md | 22 + docs/examples/domains/get-preset-i-cloud.md | 22 + docs/examples/domains/get-preset-mailgun.md | 22 + docs/examples/domains/get-preset-outlook.md | 22 + .../domains/get-preset-proton-mail.md | 22 + docs/examples/domains/get-preset-zoho.md | 22 + docs/examples/domains/get-price.md | 24 + docs/examples/domains/get-record.md | 23 + docs/examples/domains/get-transfer-status.md | 22 + docs/examples/domains/get-zone.md | 22 + docs/examples/domains/get.md | 22 + docs/examples/domains/list-prices.md | 24 + docs/examples/domains/list-records.md | 23 + docs/examples/domains/list.md | 23 + docs/examples/domains/update-nameservers.md | 23 + docs/examples/domains/update-record-a.md | 27 + docs/examples/domains/update-record-aaaa.md | 27 + docs/examples/domains/update-record-alias.md | 27 + docs/examples/domains/update-record-caa.md | 27 + docs/examples/domains/update-record-cname.md | 27 + docs/examples/domains/update-record-https.md | 27 + docs/examples/domains/update-record-mx.md | 28 + docs/examples/domains/update-record-ns.md | 27 + docs/examples/domains/update-record-srv.md | 30 + docs/examples/domains/update-record-txt.md | 27 + docs/examples/domains/update-team.md | 23 + docs/examples/domains/update-zone.md | 23 + docs/examples/domains/verify-nameservers.md | 22 + docs/examples/functions/list-runtimes.md | 4 +- .../examples/functions/list-specifications.md | 3 +- docs/examples/locale/list-codes.md | 4 +- docs/examples/locale/list-continents.md | 4 +- docs/examples/locale/list-countries-eu.md | 4 +- docs/examples/locale/list-countries-phones.md | 4 +- docs/examples/locale/list-countries.md | 4 +- docs/examples/locale/list-currencies.md | 4 +- docs/examples/locale/list-languages.md | 4 +- .../messaging/create-appwrite-provider.md | 26 + docs/examples/messaging/create-email.md | 4 +- docs/examples/messaging/create-push.md | 3 +- docs/examples/messaging/create-topic.md | 4 +- .../messaging/update-appwrite-provider.md | 26 + docs/examples/messaging/update-email.md | 4 +- docs/examples/messaging/update-push.md | 3 +- docs/examples/messaging/update-topic.md | 4 +- docs/examples/oauth2/introspect.md | 25 + .../create-ephemeral-project-key.md | 24 + .../organization/delete-project-key.md | 21 + docs/examples/organization/get-project-key.md | 23 + .../organization/list-project-keys.md | 24 + .../organization/update-project-key.md | 26 + .../project/create-android-platform.md | 3 +- docs/examples/project/create-environment.md | 23 + docs/examples/project/delete-environment.md | 20 + docs/examples/project/get-environment.md | 22 + docs/examples/project/list-environments.md | 23 + .../project/update-android-platform.md | 3 +- docs/examples/project/update-environment.md | 23 + .../examples/project/update-o-auth-2-apple.md | 2 + .../project/update-o-auth-2-auth-0.md | 3 +- .../project/update-o-auth-2-discord.md | 3 +- .../project/update-o-auth-2-git-hub.md | 3 +- .../project/update-o-auth-2-google.md | 2 + .../examples/project/update-o-auth-2-kakao.md | 25 + .../project/update-o-auth-2-microsoft.md | 3 +- docs/examples/project/update-o-auth-2-okta.md | 3 +- .../project/update-o-auth-2-salesforce.md | 3 +- .../project/update-o-auth-2-tik-tok.md | 24 + .../project/update-o-auth-2-webflow.md | 24 + docs/examples/project/update-o-auth-2-zoho.md | 3 +- .../project/update-password-pwned-policy.md | 24 + .../update-password-rotation-policy.md | 23 + docs/examples/sites/list-frameworks.md | 4 +- docs/examples/sites/list-specifications.md | 3 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/tablesdb/list-transactions.md | 3 +- docs/examples/teams/create-membership.md | 3 +- docs/examples/vectorsdb/list-transactions.md | 3 +- docs/examples/waf/create-bypass-rule.md | 29 + docs/examples/waf/create-challenge-rule.md | 32 + docs/examples/waf/create-deny-rule.md | 29 + docs/examples/waf/create-rate-limit-rule.md | 34 + docs/examples/waf/create-redirect-rule.md | 31 + docs/examples/waf/delete-rule.md | 20 + docs/examples/waf/get-rule.md | 22 + docs/examples/waf/list-rules.md | 24 + docs/examples/waf/update-bypass-rule.md | 29 + docs/examples/waf/update-challenge-rule.md | 32 + docs/examples/waf/update-deny-rule.md | 29 + docs/examples/waf/update-rate-limit-rule.md | 33 + docs/examples/waf/update-redirect-rule.md | 31 + src/client.rs | 111 +- src/enums/billing_plan_group.rs | 6 + src/enums/build_runtime.rs | 6 + src/enums/databases_index_type.rs | 3 + src/enums/domain_registration_type.rs | 32 + src/enums/domain_transfer_status_enum.rs | 44 + src/enums/framework.rs | 3 + src/enums/id_token_provider.rs | 26 + src/enums/image_gravity.rs | 3 + src/enums/mod.rs | 40 + src/enums/o_auth2_auth0_prompt.rs | 29 + src/enums/o_auth2_discord_prompt.rs | 26 + src/enums/o_auth2_github_prompt.rs | 23 + src/enums/o_auth2_kakao_prompt.rs | 32 + src/enums/o_auth2_microsoft_prompt.rs | 32 + src/enums/o_auth2_okta_prompt.rs | 29 + src/enums/o_auth2_salesforce_prompt.rs | 26 + src/enums/o_auth2_zoho_prompt.rs | 23 + src/enums/o_auth_provider.rs | 9 + src/enums/project_email_template_id.rs | 6 + src/enums/project_key_scopes.rs | 12 + src/enums/project_o_auth2_auth0_prompt.rs | 29 + src/enums/project_o_auth2_discord_prompt.rs | 26 + src/enums/project_o_auth2_git_hub_prompt.rs | 23 + src/enums/project_o_auth2_kakao_prompt.rs | 32 + src/enums/project_o_auth2_microsoft_prompt.rs | 32 + src/enums/project_o_auth2_okta_prompt.rs | 29 + .../project_o_auth2_salesforce_prompt.rs | 26 + src/enums/project_o_auth2_zoho_prompt.rs | 23 + src/enums/project_o_auth_provider_id.rs | 9 + src/enums/project_policy_id.rs | 6 + .../proxy_rule_deployment_resource_type.rs | 3 + src/enums/runtime.rs | 6 + src/enums/tables_db_index_type.rs | 3 + src/enums/waf_rule_action.rs | 35 + src/lib.rs | 4 +- src/models/account.rs | 376 ++++ src/models/billing_plan.rs | 32 + src/models/dedicated_database.rs | 47 + .../dedicated_database_specification.rs | 60 + src/models/dns_record.rs | 199 ++ src/models/dns_records_list.rs | 59 + src/models/domain.rs | 218 ++ src/models/domain_price.rs | 147 ++ src/models/domain_prices_list.rs | 59 + src/models/domain_transfer_status.rs | 73 + src/models/domains_list.rs | 59 + src/models/identity.rs | 16 + src/models/mod.rs | 60 + src/models/o_auth2_apple.rs | 33 + src/models/o_auth2_auth0.rs | 15 + src/models/o_auth2_discord.rs | 15 + src/models/o_auth2_github.rs | 15 + src/models/o_auth2_google.rs | 33 + src/models/o_auth2_kakao.rs | 101 + src/models/o_auth2_microsoft.rs | 15 + src/models/o_auth2_okta.rs | 15 + src/models/o_auth2_salesforce.rs | 15 + src/models/o_auth2_tik_tok.rs | 87 + src/models/o_auth2_webflow.rs | 87 + src/models/o_auth2_zoho.rs | 15 + src/models/oauth2_introspection.rs | 218 ++ src/models/platform_android.rs | 16 + src/models/policy_password_pwned.rs | 90 + src/models/policy_password_rotation.rs | 73 + src/models/project.rs | 48 + src/models/topic.rs | 31 + src/models/user.rs | 16 + src/models/waf_rule_bypass.rs | 222 ++ src/models/waf_rule_challenge.rs | 266 +++ src/models/waf_rule_deny.rs | 222 ++ src/models/waf_rule_list.rs | 59 + src/models/waf_rule_rate_limit.rs | 294 +++ src/models/waf_rule_redirect.rs | 250 +++ src/services/account.rs | 218 +- src/services/avatars.rs | 52 +- src/services/databases.rs | 4 + src/services/documents_db.rs | 4 + src/services/domains.rs | 1893 +++++++++++++++++ src/services/functions.rs | 14 +- src/services/locale.rs | 72 +- src/services/messaging.rs | 117 + src/services/mod.rs | 16 + src/services/oauth2.rs | 41 + src/services/organization.rs | 209 ++ src/services/project.rs | 351 +++ src/services/sites.rs | 14 +- src/services/tables_db.rs | 4 + src/services/teams.rs | 4 + src/services/vectors_db.rs | 4 + src/services/waf.rs | 787 +++++++ 215 files changed, 10425 insertions(+), 72 deletions(-) create mode 100644 docs/examples/account/create-email-verification-otp.md create mode 100644 docs/examples/account/create-id-token-session.md create mode 100644 docs/examples/account/create-recovery-otp.md create mode 100644 docs/examples/account/update-email-verification-otp.md create mode 100644 docs/examples/account/update-recovery-otp.md create mode 100644 docs/examples/avatars/delete-photo.md create mode 100644 docs/examples/avatars/update-photo.md create mode 100644 docs/examples/domains/create-preset-google-workspace.md create mode 100644 docs/examples/domains/create-preset-i-cloud.md create mode 100644 docs/examples/domains/create-preset-mailgun.md create mode 100644 docs/examples/domains/create-preset-outlook.md create mode 100644 docs/examples/domains/create-preset-proton-mail.md create mode 100644 docs/examples/domains/create-preset-zoho.md create mode 100644 docs/examples/domains/create-record-a.md create mode 100644 docs/examples/domains/create-record-aaaa.md create mode 100644 docs/examples/domains/create-record-alias.md create mode 100644 docs/examples/domains/create-record-caa.md create mode 100644 docs/examples/domains/create-record-cname.md create mode 100644 docs/examples/domains/create-record-https.md create mode 100644 docs/examples/domains/create-record-mx.md create mode 100644 docs/examples/domains/create-record-ns.md create mode 100644 docs/examples/domains/create-record-srv.md create mode 100644 docs/examples/domains/create-record-txt.md create mode 100644 docs/examples/domains/create.md create mode 100644 docs/examples/domains/delete-record.md create mode 100644 docs/examples/domains/delete.md create mode 100644 docs/examples/domains/get-preset-google-workspace.md create mode 100644 docs/examples/domains/get-preset-i-cloud.md create mode 100644 docs/examples/domains/get-preset-mailgun.md create mode 100644 docs/examples/domains/get-preset-outlook.md create mode 100644 docs/examples/domains/get-preset-proton-mail.md create mode 100644 docs/examples/domains/get-preset-zoho.md create mode 100644 docs/examples/domains/get-price.md create mode 100644 docs/examples/domains/get-record.md create mode 100644 docs/examples/domains/get-transfer-status.md create mode 100644 docs/examples/domains/get-zone.md create mode 100644 docs/examples/domains/get.md create mode 100644 docs/examples/domains/list-prices.md create mode 100644 docs/examples/domains/list-records.md create mode 100644 docs/examples/domains/list.md create mode 100644 docs/examples/domains/update-nameservers.md create mode 100644 docs/examples/domains/update-record-a.md create mode 100644 docs/examples/domains/update-record-aaaa.md create mode 100644 docs/examples/domains/update-record-alias.md create mode 100644 docs/examples/domains/update-record-caa.md create mode 100644 docs/examples/domains/update-record-cname.md create mode 100644 docs/examples/domains/update-record-https.md create mode 100644 docs/examples/domains/update-record-mx.md create mode 100644 docs/examples/domains/update-record-ns.md create mode 100644 docs/examples/domains/update-record-srv.md create mode 100644 docs/examples/domains/update-record-txt.md create mode 100644 docs/examples/domains/update-team.md create mode 100644 docs/examples/domains/update-zone.md create mode 100644 docs/examples/domains/verify-nameservers.md create mode 100644 docs/examples/messaging/create-appwrite-provider.md create mode 100644 docs/examples/messaging/update-appwrite-provider.md create mode 100644 docs/examples/oauth2/introspect.md create mode 100644 docs/examples/organization/create-ephemeral-project-key.md create mode 100644 docs/examples/organization/delete-project-key.md create mode 100644 docs/examples/organization/get-project-key.md create mode 100644 docs/examples/organization/list-project-keys.md create mode 100644 docs/examples/organization/update-project-key.md create mode 100644 docs/examples/project/create-environment.md create mode 100644 docs/examples/project/delete-environment.md create mode 100644 docs/examples/project/get-environment.md create mode 100644 docs/examples/project/list-environments.md create mode 100644 docs/examples/project/update-environment.md create mode 100644 docs/examples/project/update-o-auth-2-kakao.md create mode 100644 docs/examples/project/update-o-auth-2-tik-tok.md create mode 100644 docs/examples/project/update-o-auth-2-webflow.md create mode 100644 docs/examples/project/update-password-pwned-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 src/enums/domain_registration_type.rs create mode 100644 src/enums/domain_transfer_status_enum.rs create mode 100644 src/enums/id_token_provider.rs create mode 100644 src/enums/o_auth2_auth0_prompt.rs create mode 100644 src/enums/o_auth2_discord_prompt.rs create mode 100644 src/enums/o_auth2_github_prompt.rs create mode 100644 src/enums/o_auth2_kakao_prompt.rs create mode 100644 src/enums/o_auth2_microsoft_prompt.rs create mode 100644 src/enums/o_auth2_okta_prompt.rs create mode 100644 src/enums/o_auth2_salesforce_prompt.rs create mode 100644 src/enums/o_auth2_zoho_prompt.rs create mode 100644 src/enums/project_o_auth2_auth0_prompt.rs create mode 100644 src/enums/project_o_auth2_discord_prompt.rs create mode 100644 src/enums/project_o_auth2_git_hub_prompt.rs create mode 100644 src/enums/project_o_auth2_kakao_prompt.rs create mode 100644 src/enums/project_o_auth2_microsoft_prompt.rs create mode 100644 src/enums/project_o_auth2_okta_prompt.rs create mode 100644 src/enums/project_o_auth2_salesforce_prompt.rs create mode 100644 src/enums/project_o_auth2_zoho_prompt.rs create mode 100644 src/enums/waf_rule_action.rs create mode 100644 src/models/account.rs create mode 100644 src/models/dns_record.rs create mode 100644 src/models/dns_records_list.rs create mode 100644 src/models/domain.rs create mode 100644 src/models/domain_price.rs create mode 100644 src/models/domain_prices_list.rs create mode 100644 src/models/domain_transfer_status.rs create mode 100644 src/models/domains_list.rs create mode 100644 src/models/o_auth2_kakao.rs create mode 100644 src/models/o_auth2_tik_tok.rs create mode 100644 src/models/o_auth2_webflow.rs create mode 100644 src/models/oauth2_introspection.rs create mode 100644 src/models/policy_password_pwned.rs create mode 100644 src/models/policy_password_rotation.rs create mode 100644 src/models/waf_rule_bypass.rs create mode 100644 src/models/waf_rule_challenge.rs create mode 100644 src/models/waf_rule_deny.rs create mode 100644 src/models/waf_rule_list.rs create mode 100644 src/models/waf_rule_rate_limit.rs create mode 100644 src/models/waf_rule_redirect.rs create mode 100644 src/services/domains.rs create mode 100644 src/services/waf.rs diff --git a/Cargo.toml b/Cargo.toml index 824f1fc..b5198a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "appwrite" -version = "0.18.0" +version = "0.19.0" edition = "2021" rust-version = "1.83" authors = ["appwrite"] diff --git a/README.md b/README.md index 1fa162f..3b784e1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -appwrite = "0.18.0" +appwrite = "0.19.0" tokio = { version = "1.48", features = ["full"] } ``` diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index ac72db1..644ba25 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -13,7 +13,8 @@ async fn main() -> Result<(), Box> { let result = account.create_email_password_session( "email@example.com", - "password" + "password", + Some(60) // optional ).await?; let _ = result; diff --git a/docs/examples/account/create-email-verification-otp.md b/docs/examples/account/create-email-verification-otp.md new file mode 100644 index 0000000..5b6b83c --- /dev/null +++ b/docs/examples/account/create-email-verification-otp.md @@ -0,0 +1,22 @@ +```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.create_email_verification_otp( + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md new file mode 100644 index 0000000..37993ba --- /dev/null +++ b/docs/examples/account/create-id-token-session.md @@ -0,0 +1,27 @@ +```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.create_id_token_session( + appwrite::enums::IdTokenProvider::Apple, + "", + Some(""), // optional + Some(""), // optional + Some(0), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/account/create-recovery-otp.md b/docs/examples/account/create-recovery-otp.md new file mode 100644 index 0000000..4c9f08d --- /dev/null +++ b/docs/examples/account/create-recovery-otp.md @@ -0,0 +1,23 @@ +```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.create_recovery_otp( + "email@example.com", + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index ee557af..cc496e4 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - account.delete_sessions().await?; + account.delete_sessions( + Some(false) // optional + ).await?; Ok(()) } diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 5a2af59..bd2ac05 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let account = Account::new(&client); - let result = account.list_sessions().await?; + let result = account.list_sessions( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/account/update-email-verification-otp.md b/docs/examples/account/update-email-verification-otp.md new file mode 100644 index 0000000..1670c98 --- /dev/null +++ b/docs/examples/account/update-email-verification-otp.md @@ -0,0 +1,23 @@ +```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.update_email_verification_otp( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md new file mode 100644 index 0000000..a6bc18c --- /dev/null +++ b/docs/examples/account/update-recovery-otp.md @@ -0,0 +1,24 @@ +```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.update_recovery_otp( + "", + "", + "password" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/avatars/delete-photo.md b/docs/examples/avatars/delete-photo.md new file mode 100644 index 0000000..899ed00 --- /dev/null +++ b/docs/examples/avatars/delete-photo.md @@ -0,0 +1,18 @@ +```rust +use appwrite::Client; +use appwrite::services::Avatars; + +#[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 avatars = Avatars::new(&client); + + avatars.delete_photo().await?; + + Ok(()) +} +``` diff --git a/docs/examples/avatars/update-photo.md b/docs/examples/avatars/update-photo.md new file mode 100644 index 0000000..f5c13e6 --- /dev/null +++ b/docs/examples/avatars/update-photo.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Avatars; +use appwrite::InputFile; + +#[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 avatars = Avatars::new(&client); + + let file = InputFile::from_path("path/to/file.png", None).await?; + + let result = avatars.update_photo( + file + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index 6570a83..94147a6 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -12,7 +12,8 @@ async fn main() -> Result<(), Box> { let databases = Databases::new(&client); let result = databases.list_transactions( - Some(vec![]) // optional + Some(vec![]), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 9f387f6..2029d4c 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -12,7 +12,8 @@ async fn main() -> Result<(), Box> { let documents_db = DocumentsDB::new(&client); let result = documents_db.list_transactions( - Some(vec![]) // optional + Some(vec![]), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/domains/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md new file mode 100644 index 0000000..20d8782 --- /dev/null +++ b/docs/examples/domains/create-preset-google-workspace.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_preset_google_workspace( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md new file mode 100644 index 0000000..1cace5a --- /dev/null +++ b/docs/examples/domains/create-preset-i-cloud.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_preset_i_cloud( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md new file mode 100644 index 0000000..2168ee7 --- /dev/null +++ b/docs/examples/domains/create-preset-mailgun.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_preset_mailgun( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md new file mode 100644 index 0000000..4349c8b --- /dev/null +++ b/docs/examples/domains/create-preset-outlook.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_preset_outlook( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md new file mode 100644 index 0000000..3aef9bb --- /dev/null +++ b/docs/examples/domains/create-preset-proton-mail.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_preset_proton_mail( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md new file mode 100644 index 0000000..001f0f5 --- /dev/null +++ b/docs/examples/domains/create-preset-zoho.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_preset_zoho( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md new file mode 100644 index 0000000..d319eb5 --- /dev/null +++ b/docs/examples/domains/create-record-a.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_a( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md new file mode 100644 index 0000000..adb4229 --- /dev/null +++ b/docs/examples/domains/create-record-aaaa.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_aaaa( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md new file mode 100644 index 0000000..6a903ec --- /dev/null +++ b/docs/examples/domains/create-record-alias.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_alias( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md new file mode 100644 index 0000000..c35b5e2 --- /dev/null +++ b/docs/examples/domains/create-record-caa.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_caa( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md new file mode 100644 index 0000000..662293f --- /dev/null +++ b/docs/examples/domains/create-record-cname.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_cname( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md new file mode 100644 index 0000000..39f845f --- /dev/null +++ b/docs/examples/domains/create-record-https.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_https( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md new file mode 100644 index 0000000..f4cf2c8 --- /dev/null +++ b/docs/examples/domains/create-record-mx.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_mx( + "", + "", + "", + 1, + 0, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md new file mode 100644 index 0000000..2b605b1 --- /dev/null +++ b/docs/examples/domains/create-record-ns.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_ns( + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md new file mode 100644 index 0000000..012de94 --- /dev/null +++ b/docs/examples/domains/create-record-srv.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_srv( + "", + "", + "", + 1, + 0, + 0, + 0, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md new file mode 100644 index 0000000..76d67f0 --- /dev/null +++ b/docs/examples/domains/create-record-txt.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create_record_txt( + "", + "", + 1, + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md new file mode 100644 index 0000000..8d13879 --- /dev/null +++ b/docs/examples/domains/create.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.create( + "", + "example.com" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md new file mode 100644 index 0000000..4f03bfe --- /dev/null +++ b/docs/examples/domains/delete-record.md @@ -0,0 +1,21 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + domains.delete_record( + "", + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md new file mode 100644 index 0000000..f59ede6 --- /dev/null +++ b/docs/examples/domains/delete.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + domains.delete( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md new file mode 100644 index 0000000..03b8bae --- /dev/null +++ b/docs/examples/domains/get-preset-google-workspace.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_preset_google_workspace( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md new file mode 100644 index 0000000..0da98fe --- /dev/null +++ b/docs/examples/domains/get-preset-i-cloud.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_preset_i_cloud( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md new file mode 100644 index 0000000..fe51c20 --- /dev/null +++ b/docs/examples/domains/get-preset-mailgun.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_preset_mailgun( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md new file mode 100644 index 0000000..99b4720 --- /dev/null +++ b/docs/examples/domains/get-preset-outlook.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_preset_outlook( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md new file mode 100644 index 0000000..60251f9 --- /dev/null +++ b/docs/examples/domains/get-preset-proton-mail.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_preset_proton_mail( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md new file mode 100644 index 0000000..b1fd67d --- /dev/null +++ b/docs/examples/domains/get-preset-zoho.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_preset_zoho( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md new file mode 100644 index 0000000..d6cdc47 --- /dev/null +++ b/docs/examples/domains/get-price.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_price( + "example.com", + Some(0), // optional + Some(appwrite::enums::DomainRegistrationType::New) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md new file mode 100644 index 0000000..5b37a1c --- /dev/null +++ b/docs/examples/domains/get-record.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_record( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md new file mode 100644 index 0000000..b6289be --- /dev/null +++ b/docs/examples/domains/get-transfer-status.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_transfer_status( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md new file mode 100644 index 0000000..1dad4e9 --- /dev/null +++ b/docs/examples/domains/get-zone.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get_zone( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md new file mode 100644 index 0000000..3b319b7 --- /dev/null +++ b/docs/examples/domains/get.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.get( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md new file mode 100644 index 0000000..f38d1f5 --- /dev/null +++ b/docs/examples/domains/list-prices.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.list_prices( + vec![], + Some(0), // optional + Some(appwrite::enums::DomainRegistrationType::New) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md new file mode 100644 index 0000000..3b9aa99 --- /dev/null +++ b/docs/examples/domains/list-records.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.list_records( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md new file mode 100644 index 0000000..86d358e --- /dev/null +++ b/docs/examples/domains/list.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.list( + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md new file mode 100644 index 0000000..1c33784 --- /dev/null +++ b/docs/examples/domains/update-nameservers.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_nameservers( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md new file mode 100644 index 0000000..3c1ded5 --- /dev/null +++ b/docs/examples/domains/update-record-a.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_a( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md new file mode 100644 index 0000000..022a896 --- /dev/null +++ b/docs/examples/domains/update-record-aaaa.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_aaaa( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md new file mode 100644 index 0000000..ba0a3a2 --- /dev/null +++ b/docs/examples/domains/update-record-alias.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_alias( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md new file mode 100644 index 0000000..cceec8b --- /dev/null +++ b/docs/examples/domains/update-record-caa.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_caa( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md new file mode 100644 index 0000000..32d038b --- /dev/null +++ b/docs/examples/domains/update-record-cname.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_cname( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md new file mode 100644 index 0000000..5967899 --- /dev/null +++ b/docs/examples/domains/update-record-https.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_https( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md new file mode 100644 index 0000000..fdfb079 --- /dev/null +++ b/docs/examples/domains/update-record-mx.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_mx( + "", + "", + "", + "", + 1, + 0, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md new file mode 100644 index 0000000..7e6d33a --- /dev/null +++ b/docs/examples/domains/update-record-ns.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_ns( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md new file mode 100644 index 0000000..cdeec2b --- /dev/null +++ b/docs/examples/domains/update-record-srv.md @@ -0,0 +1,30 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_srv( + "", + "", + "", + "", + 1, + 0, + 0, + 0, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md new file mode 100644 index 0000000..21e2630 --- /dev/null +++ b/docs/examples/domains/update-record-txt.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_record_txt( + "", + "", + "", + "", + 1, + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md new file mode 100644 index 0000000..8307703 --- /dev/null +++ b/docs/examples/domains/update-team.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_team( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md new file mode 100644 index 0000000..61e3f5a --- /dev/null +++ b/docs/examples/domains/update-zone.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.update_zone( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md new file mode 100644 index 0000000..e496bf8 --- /dev/null +++ b/docs/examples/domains/verify-nameservers.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Domains; + +#[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 domains = Domains::new(&client); + + let result = domains.verify_nameservers( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index abeffc7..01b5e11 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let functions = Functions::new(&client); - let result = functions.list_runtimes().await?; + let result = functions.list_runtimes( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index 57245ba..cbce650 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -12,7 +12,8 @@ async fn main() -> Result<(), Box> { let functions = Functions::new(&client); let result = functions.list_specifications( - Some("runtimes") // optional + Some("runtimes"), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index f920bf6..6073c9d 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_codes().await?; + let result = locale.list_codes( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index b4f8d46..a995768 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_continents().await?; + let result = locale.list_continents( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index c959aa1..0f6bdd7 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_countries_eu().await?; + let result = locale.list_countries_eu( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 6c0238b..9a94928 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_countries_phones().await?; + let result = locale.list_countries_phones( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index bd8f795..980168f 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_countries().await?; + let result = locale.list_countries( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index b382da6..c9d2414 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_currencies().await?; + let result = locale.list_currencies( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index fb7c78a..2fad70d 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let locale = Locale::new(&client); - let result = locale.list_languages().await?; + let result = locale.list_languages( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md new file mode 100644 index 0000000..4fca67c --- /dev/null +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Messaging; + +#[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 messaging = Messaging::new(&client); + + let result = messaging.create_appwrite_provider( + "", + "", + Some(false), // optional + Some(0), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 74ffddc..a18138a 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -23,7 +23,9 @@ async fn main() -> Result<(), Box> { Some(vec![]), // optional Some(false), // optional Some(false), // optional - Some("2020-10-15T06:38:00.000+00:00") // optional + Some("2020-10-15T06:38:00.000+00:00"), // optional + Some("email@example.com"), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 7f93d6b..ea3c679 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -30,7 +30,8 @@ async fn main() -> Result<(), Box> { Some("2020-10-15T06:38:00.000+00:00"), // optional Some(false), // optional Some(false), // optional - Some(appwrite::enums::MessagePriority::Normal) // optional + Some(appwrite::enums::MessagePriority::Normal), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 9b2108f..b1dcdb0 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -14,7 +14,9 @@ async fn main() -> Result<(), Box> { let result = messaging.create_topic( "", "", - Some(vec!["any".into()]) // optional + Some(vec!["any".into()]), // optional + Some(0), // optional + Some(0) // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md new file mode 100644 index 0000000..ef0e371 --- /dev/null +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Messaging; + +#[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 messaging = Messaging::new(&client); + + let result = messaging.update_appwrite_provider( + "", + Some(""), // optional + Some(false), // optional + Some(0), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 0728e91..0743d5b 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -23,7 +23,9 @@ async fn main() -> Result<(), Box> { Some(vec![]), // optional Some(vec![]), // optional Some("2020-10-15T06:38:00.000+00:00"), // optional - Some(vec![]) // optional + Some(vec![]), // optional + Some("email@example.com"), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 00fdc77..ba08c53 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -30,7 +30,8 @@ async fn main() -> Result<(), Box> { Some("2020-10-15T06:38:00.000+00:00"), // optional Some(false), // optional Some(false), // optional - Some(appwrite::enums::MessagePriority::Normal) // optional + Some(appwrite::enums::MessagePriority::Normal), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 9f112ff..ddef290 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -14,7 +14,9 @@ async fn main() -> Result<(), Box> { let result = messaging.update_topic( "", Some(""), // optional - Some(vec!["any".into()]) // optional + Some(vec!["any".into()]), // optional + Some(0), // optional + Some(0) // optional ).await?; let _ = result; diff --git a/docs/examples/oauth2/introspect.md b/docs/examples/oauth2/introspect.md new file mode 100644 index 0000000..e43d646 --- /dev/null +++ b/docs/examples/oauth2/introspect.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Oauth2; + +#[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 oauth2 = Oauth2::new(&client); + + let result = oauth2.introspect( + "", + Some("access_token"), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md new file mode 100644 index 0000000..b7655a9 --- /dev/null +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -0,0 +1,24 @@ +```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_ephemeral_project_key( + "", + vec![appwrite::enums::ProjectKeyScopes::UsersRead], + 600 + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/organization/delete-project-key.md b/docs/examples/organization/delete-project-key.md new file mode 100644 index 0000000..4f08719 --- /dev/null +++ b/docs/examples/organization/delete-project-key.md @@ -0,0 +1,21 @@ +```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_project_key( + "", + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/organization/get-project-key.md b/docs/examples/organization/get-project-key.md new file mode 100644 index 0000000..707dea4 --- /dev/null +++ b/docs/examples/organization/get-project-key.md @@ -0,0 +1,23 @@ +```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_project_key( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/organization/list-project-keys.md b/docs/examples/organization/list-project-keys.md new file mode 100644 index 0000000..b7d1f50 --- /dev/null +++ b/docs/examples/organization/list-project-keys.md @@ -0,0 +1,24 @@ +```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_project_keys( + "", + Some(vec![]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md new file mode 100644 index 0000000..9636247 --- /dev/null +++ b/docs/examples/organization/update-project-key.md @@ -0,0 +1,26 @@ +```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_project_key( + "", + "", + "", + vec![appwrite::enums::ProjectKeyScopes::UsersRead], + Some("2020-10-15T06:38:00.000+00:00") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 98c013f..133832e 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -14,7 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.create_android_platform( "", "", - "" + "", + Some(vec![]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 0000000..62268ef --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.create_environment( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 0000000..23d441d --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + project.delete_environment( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 0000000..53f0290 --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.get_environment( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 0000000..1c726d0 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.list_environments( + Some(vec![]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index 4240a36..7e712ee 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -14,7 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_android_platform( "", "", - "" + "", + Some(vec![]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 0000000..b6f112b --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.update_environment( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 428de09..977f613 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -16,6 +16,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional + Some(false), // optional + Some(vec![]), // optional Some(false) // optional ).await?; diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 811a8c8..d7cec31 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -15,7 +15,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2Auth0Prompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 783c9b8..9a39250 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -14,7 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_discord( Some(""), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2DiscordPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index be26e71..f5c7091 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -14,7 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_git_hub( Some(""), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2GitHubPrompt::SelectAccount]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 2a96b7b..2ea8038 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -15,6 +15,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(vec![appwrite::enums::ProjectOAuth2GooglePrompt::None]), // optional + Some(false), // optional + Some(vec![]), // optional Some(false) // optional ).await?; diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md new file mode 100644 index 0000000..f96eb6e --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.update_o_auth2_kakao( + Some(""), // optional + Some(""), // optional + Some(vec![appwrite::enums::ProjectOAuth2KakaoPrompt::None]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index f32216e..ab5e208 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -15,7 +15,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2MicrosoftPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 5273104..437955a 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -16,7 +16,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some("example.com"), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2OktaPrompt::None]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index dd41c0a..562ee8b 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -14,7 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_salesforce( Some(""), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2SalesforcePrompt::Login]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md new file mode 100644 index 0000000..8eec70c --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tik-tok.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.update_o_auth2_tik_tok( + Some(""), // optional + Some(""), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-o-auth-2-webflow.md b/docs/examples/project/update-o-auth-2-webflow.md new file mode 100644 index 0000000..d0df8ea --- /dev/null +++ b/docs/examples/project/update-o-auth-2-webflow.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.update_o_auth2_webflow( + Some(""), // optional + Some(""), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 62ac858..d29119f 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -14,7 +14,8 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_zoho( Some(""), // optional Some(""), // optional - Some(false) // optional + Some(false), // optional + Some(vec![appwrite::enums::ProjectOAuth2ZohoPrompt::Consent]) // optional ).await?; let _ = result; diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md new file mode 100644 index 0000000..b3a2a6e --- /dev/null +++ b/docs/examples/project/update-password-pwned-policy.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.update_password_pwned_policy( + Some(false), // optional + Some(false), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 0000000..5e3e339 --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Project; + +#[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 project = Project::new(&client); + + let result = project.update_password_rotation_policy( + Some(false), // optional + Some(86400) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index 1252124..4dce7ea 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -11,7 +11,9 @@ async fn main() -> Result<(), Box> { let sites = Sites::new(&client); - let result = sites.list_frameworks().await?; + let result = sites.list_frameworks( + Some(false) // optional + ).await?; let _ = result; diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 4736fb7..4addba6 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -12,7 +12,8 @@ async fn main() -> Result<(), Box> { let sites = Sites::new(&client); let result = sites.list_specifications( - Some("runtimes") // optional + Some("runtimes"), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index f8f2406..3246e90 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box> { "", Some(0), // optional Some(0), // optional - Some(appwrite::enums::ImageGravity::Center), // optional + Some(appwrite::enums::ImageGravity::Auto), // optional Some(-1), // optional Some(0), // optional Some("FFFFFF"), // optional diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index 0479742..9144941 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -12,7 +12,8 @@ async fn main() -> Result<(), Box> { let tables_db = TablesDB::new(&client); let result = tables_db.list_transactions( - Some(vec![]) // optional + Some(vec![]), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 5366d5e..bb83298 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -18,7 +18,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some("+12065550100"), // optional Some("https://example.com"), // optional - Some("") // optional + Some(""), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index 214670d..b8eb22e 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -12,7 +12,8 @@ async fn main() -> Result<(), Box> { let vectors_db = VectorsDB::new(&client); let result = vectors_db.list_transactions( - Some(vec![]) // optional + Some(vec![]), // optional + Some(false) // optional ).await?; let _ = result; diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 0000000..5f233dc --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.create_bypass_rule( + "", + "api", + "", + Some(""), // optional + Some(""), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 0000000..4fb4848 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,32 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.create_challenge_rule( + "", + "api", + "", + Some(""), // optional + Some(""), // optional + Some("compute"), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]), // optional + Some(1), // optional + Some(900) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 0000000..eb735bd --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.create_deny_rule( + "", + "api", + "", + Some(""), // optional + Some(""), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 0000000..8d6cf9f --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,34 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.create_rate_limit_rule( + "", + "api", + "", + 1, + 1, + Some(""), // optional + Some(""), // optional + Some("ip"), // optional + Some("fixedWindow"), // optional + Some(1), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 0000000..8b9e352 --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,31 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.create_redirect_rule( + "", + "api", + "", + "", + 300, + Some(""), // optional + Some(""), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 0000000..b6eed88 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + waf.delete_rule( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 0000000..fbb9a6b --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.get_rule( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 0000000..d392122 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.list_rules( + Some(vec![]), // optional + Some(""), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 0000000..06b6d8c --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.update_bypass_rule( + "", + Some("api"), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 0000000..58a0fc2 --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,32 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.update_challenge_rule( + "", + Some("api"), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some("compute"), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]), // optional + Some(1), // optional + Some(900) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 0000000..1711ada --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.update_deny_rule( + "", + Some("api"), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 0000000..e23ea2e --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,33 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.update_rate_limit_rule( + "", + Some("api"), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some(1), // optional + Some(1), // optional + Some("ip"), // optional + Some(1), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 0000000..23b125d --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,31 @@ +```rust +use appwrite::Client; +use appwrite::services::Waf; + +#[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 waf = Waf::new(&client); + + let result = waf.update_redirect_rule( + "", + Some("api"), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some(300), // optional + Some(-100000), // optional + Some(false), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/src/client.rs b/src/client.rs index 14e1ca1..7db52e8 100644 --- a/src/client.rs +++ b/src/client.rs @@ -95,7 +95,7 @@ impl Client { headers.insert( "user-agent", format!( - "AppwriteRustSDK/0.18.0 ({}; {})", + "AppwriteRustSDK/0.19.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH ) @@ -105,7 +105,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.18.0".parse().unwrap()); + headers.insert("x-sdk-version", "0.19.0".parse().unwrap()); let config = Config { endpoint: "https://cloud.appwrite.io/v1".to_string(), @@ -554,6 +554,34 @@ 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) + .await + .map(|_| String::new()) + } + + async fn request( + &self, + method: Method, + path: &str, + headers: Option>, + params: Option>, + ) -> Result { let state = self.state.load_full(); let url = format!("{}{}", state.config.endpoint, path); let mut request_builder; @@ -586,8 +614,7 @@ impl Client { } } - let response = request_builder.send().await?; - self.handle_response(response).await + Ok(request_builder.send().await?) } /// Make an API call that returns a location/redirect URL (for webAuth endpoints) @@ -784,7 +811,32 @@ impl Client { input_file: InputFile, upload_id: Option, ) -> Result { - self.file_upload_with_progress( + self.upload( + Method::POST, + path, + headers, + params, + param_name, + input_file, + upload_id, + ) + .await + } + + /// Upload a file with the endpoint's HTTP method + #[allow(clippy::too_many_arguments)] + pub async fn upload( + &self, + method: Method, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + upload_id: Option, + ) -> Result { + self.upload_with_progress( + method, path, headers, params, @@ -809,6 +861,33 @@ impl Client { input_file: InputFile, options: UploadOptions, ) -> Result + where + F: Fn(UploadProgress), + { + self.upload_with_progress( + Method::POST, + path, + headers, + params, + param_name, + input_file, + options, + ) + .await + } + + /// 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, + path: &str, + headers: Option>, + params: HashMap, + param_name: &str, + input_file: InputFile, + options: UploadOptions, + ) -> Result where F: Fn(UploadProgress), { @@ -823,7 +902,7 @@ impl Client { let url = format!("{}{}", state.config.endpoint, path); let result = self - .single_file_upload(&url, headers, params, param_name, &input_file) + .single_file_upload(method, &url, headers, params, param_name, &input_file) .await?; if let Some(callback) = &options.on_progress { @@ -839,6 +918,7 @@ impl Client { } self.chunked_file_upload_with_progress( + method, path, headers, params, @@ -851,6 +931,7 @@ impl Client { async fn single_file_upload( &self, + method: Method, url: &str, headers: Option>, params: HashMap, @@ -884,7 +965,10 @@ impl Client { form = form.text(key, value_str); } - let mut request_builder = state.http.post(url).headers(state.config.headers.clone()); + let mut request_builder = state + .http + .request(method, url) + .headers(state.config.headers.clone()); if let Some(custom_headers) = headers { for (key, value) in custom_headers { @@ -900,8 +984,10 @@ impl Client { self.handle_response(response).await } + #[allow(clippy::too_many_arguments)] async fn chunked_file_upload_with_progress( &self, + method: Method, path: &str, headers: Option>, params: HashMap, @@ -956,6 +1042,7 @@ impl Client { if next_chunk == 0 { let result = self .upload_file_chunk( + method.clone(), path, headers.clone(), params.clone(), @@ -1003,10 +1090,12 @@ 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 .upload_file_chunk( + method, &path, headers, params, @@ -1062,10 +1151,12 @@ 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 .upload_file_chunk( + method, &path, headers, params, @@ -1092,6 +1183,7 @@ impl Client { async fn upload_file_chunk( &self, + method: Method, path: &str, headers: Option>, params: HashMap, @@ -1147,7 +1239,10 @@ impl Client { } let url = format!("{}{}", state.config.endpoint, path); - let mut request_builder = state.http.post(url).headers(state.config.headers.clone()); + let mut request_builder = state + .http + .request(method, url) + .headers(state.config.headers.clone()); if let Some(custom_headers) = headers { for (key, value) in custom_headers { diff --git a/src/enums/billing_plan_group.rs b/src/enums/billing_plan_group.rs index f18dce8..9557243 100644 --- a/src/enums/billing_plan_group.rs +++ b/src/enums/billing_plan_group.rs @@ -5,6 +5,10 @@ pub enum BillingPlanGroup { #[serde(rename = "starter")] #[default] Starter, + #[serde(rename = "free")] + Free, + #[serde(rename = "start")] + Start, #[serde(rename = "pro")] Pro, #[serde(rename = "scale")] @@ -16,6 +20,8 @@ impl BillingPlanGroup { pub fn as_str(&self) -> &str { match self { BillingPlanGroup::Starter => "starter", + BillingPlanGroup::Free => "free", + BillingPlanGroup::Start => "start", BillingPlanGroup::Pro => "pro", BillingPlanGroup::Scale => "scale", } diff --git a/src/enums/build_runtime.rs b/src/enums/build_runtime.rs index 91ffc1b..91cb47a 100644 --- a/src/enums/build_runtime.rs +++ b/src/enums/build_runtime.rs @@ -105,6 +105,8 @@ pub enum BuildRuntime { Dart311, #[serde(rename = "dart-3.12")] Dart312, + #[serde(rename = "dart-3.13")] + Dart313, #[serde(rename = "dotnet-6.0")] Dotnet60, #[serde(rename = "dotnet-7.0")] @@ -189,6 +191,8 @@ pub enum BuildRuntime { Flutter341, #[serde(rename = "flutter-3.44")] Flutter344, + #[serde(rename = "flutter-3.47")] + Flutter347, } impl BuildRuntime { @@ -246,6 +250,7 @@ impl BuildRuntime { BuildRuntime::Dart310 => "dart-3.10", BuildRuntime::Dart311 => "dart-3.11", BuildRuntime::Dart312 => "dart-3.12", + BuildRuntime::Dart313 => "dart-3.13", BuildRuntime::Dotnet60 => "dotnet-6.0", BuildRuntime::Dotnet70 => "dotnet-7.0", BuildRuntime::Dotnet80 => "dotnet-8.0", @@ -288,6 +293,7 @@ impl BuildRuntime { BuildRuntime::Flutter338 => "flutter-3.38", BuildRuntime::Flutter341 => "flutter-3.41", BuildRuntime::Flutter344 => "flutter-3.44", + BuildRuntime::Flutter347 => "flutter-3.47", } } } diff --git a/src/enums/databases_index_type.rs b/src/enums/databases_index_type.rs index 1d165b5..b924db9 100644 --- a/src/enums/databases_index_type.rs +++ b/src/enums/databases_index_type.rs @@ -11,6 +11,8 @@ pub enum DatabasesIndexType { Unique, #[serde(rename = "spatial")] Spatial, + #[serde(rename = "trigram")] + Trigram, } impl DatabasesIndexType { @@ -21,6 +23,7 @@ impl DatabasesIndexType { DatabasesIndexType::Fulltext => "fulltext", DatabasesIndexType::Unique => "unique", DatabasesIndexType::Spatial => "spatial", + DatabasesIndexType::Trigram => "trigram", } } } diff --git a/src/enums/domain_registration_type.rs b/src/enums/domain_registration_type.rs new file mode 100644 index 0000000..56a35b0 --- /dev/null +++ b/src/enums/domain_registration_type.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum DomainRegistrationType { + #[serde(rename = "new")] + #[default] + New, + #[serde(rename = "transfer")] + Transfer, + #[serde(rename = "renewal")] + Renewal, + #[serde(rename = "trade")] + Trade, +} + +impl DomainRegistrationType { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + DomainRegistrationType::New => "new", + DomainRegistrationType::Transfer => "transfer", + DomainRegistrationType::Renewal => "renewal", + DomainRegistrationType::Trade => "trade", + } + } +} + +impl std::fmt::Display for DomainRegistrationType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/domain_transfer_status_enum.rs b/src/enums/domain_transfer_status_enum.rs new file mode 100644 index 0000000..833dfbc --- /dev/null +++ b/src/enums/domain_transfer_status_enum.rs @@ -0,0 +1,44 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum DomainTransferStatusEnum { + #[serde(rename = "transferrable")] + #[default] + Transferrable, + #[serde(rename = "not_transferrable")] + NotTransferrable, + #[serde(rename = "pending_owner")] + PendingOwner, + #[serde(rename = "pending_admin")] + PendingAdmin, + #[serde(rename = "pending_registry")] + PendingRegistry, + #[serde(rename = "completed")] + Completed, + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "service_unavailable")] + ServiceUnavailable, +} + +impl DomainTransferStatusEnum { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + DomainTransferStatusEnum::Transferrable => "transferrable", + DomainTransferStatusEnum::NotTransferrable => "not_transferrable", + DomainTransferStatusEnum::PendingOwner => "pending_owner", + DomainTransferStatusEnum::PendingAdmin => "pending_admin", + DomainTransferStatusEnum::PendingRegistry => "pending_registry", + DomainTransferStatusEnum::Completed => "completed", + DomainTransferStatusEnum::Cancelled => "cancelled", + DomainTransferStatusEnum::ServiceUnavailable => "service_unavailable", + } + } +} + +impl std::fmt::Display for DomainTransferStatusEnum { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/framework.rs b/src/enums/framework.rs index a61e7e7..f73382c 100644 --- a/src/enums/framework.rs +++ b/src/enums/framework.rs @@ -27,6 +27,8 @@ pub enum Framework { Lynx, #[serde(rename = "flutter")] Flutter, + #[serde(rename = "jaspr")] + Jaspr, #[serde(rename = "react-native")] ReactNative, #[serde(rename = "vite")] @@ -51,6 +53,7 @@ impl Framework { Framework::Remix => "remix", Framework::Lynx => "lynx", Framework::Flutter => "flutter", + Framework::Jaspr => "jaspr", Framework::ReactNative => "react-native", Framework::Vite => "vite", Framework::Other => "other", diff --git a/src/enums/id_token_provider.rs b/src/enums/id_token_provider.rs new file mode 100644 index 0000000..a30f31d --- /dev/null +++ b/src/enums/id_token_provider.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum IdTokenProvider { + #[serde(rename = "apple")] + #[default] + Apple, + #[serde(rename = "google")] + Google, +} + +impl IdTokenProvider { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + IdTokenProvider::Apple => "apple", + IdTokenProvider::Google => "google", + } + } +} + +impl std::fmt::Display for IdTokenProvider { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/image_gravity.rs b/src/enums/image_gravity.rs index 18d07bb..202aa5e 100644 --- a/src/enums/image_gravity.rs +++ b/src/enums/image_gravity.rs @@ -21,6 +21,8 @@ pub enum ImageGravity { Bottom, #[serde(rename = "bottom-right")] BottomRight, + #[serde(rename = "auto")] + Auto, } impl ImageGravity { @@ -36,6 +38,7 @@ 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 7f04bf1..91c4db1 100644 --- a/src/enums/mod.rs +++ b/src/enums/mod.rs @@ -4,6 +4,8 @@ pub mod authenticator_type; pub use authenticator_type::AuthenticatorType; pub mod authentication_factor; pub use authentication_factor::AuthenticationFactor; +pub mod id_token_provider; +pub use id_token_provider::IdTokenProvider; pub mod o_auth_provider; pub use o_auth_provider::OAuthProvider; pub mod browser; @@ -32,6 +34,8 @@ pub mod order_by; pub use order_by::OrderBy; pub mod documents_db_index_type; pub use documents_db_index_type::DocumentsDBIndexType; +pub mod domain_registration_type; +pub use domain_registration_type::DomainRegistrationType; pub mod embedding_model; pub use embedding_model::EmbeddingModel; pub mod runtime; @@ -56,10 +60,26 @@ pub mod region; pub use region::Region; pub mod project_auth_method_id; pub use project_auth_method_id::ProjectAuthMethodId; +pub mod project_o_auth2_auth0_prompt; +pub use project_o_auth2_auth0_prompt::ProjectOAuth2Auth0Prompt; +pub mod project_o_auth2_discord_prompt; +pub use project_o_auth2_discord_prompt::ProjectOAuth2DiscordPrompt; +pub mod project_o_auth2_git_hub_prompt; +pub use project_o_auth2_git_hub_prompt::ProjectOAuth2GitHubPrompt; pub mod project_o_auth2_google_prompt; pub use project_o_auth2_google_prompt::ProjectOAuth2GooglePrompt; +pub mod project_o_auth2_kakao_prompt; +pub use project_o_auth2_kakao_prompt::ProjectOAuth2KakaoPrompt; +pub mod project_o_auth2_microsoft_prompt; +pub use project_o_auth2_microsoft_prompt::ProjectOAuth2MicrosoftPrompt; pub mod project_o_auth2_oidc_prompt; pub use project_o_auth2_oidc_prompt::ProjectOAuth2OidcPrompt; +pub mod project_o_auth2_okta_prompt; +pub use project_o_auth2_okta_prompt::ProjectOAuth2OktaPrompt; +pub mod project_o_auth2_salesforce_prompt; +pub use project_o_auth2_salesforce_prompt::ProjectOAuth2SalesforcePrompt; +pub mod project_o_auth2_zoho_prompt; +pub use project_o_auth2_zoho_prompt::ProjectOAuth2ZohoPrompt; pub mod project_o_auth_provider_id; pub use project_o_auth_provider_id::ProjectOAuthProviderId; pub mod project_policy_id; @@ -116,10 +136,26 @@ pub mod execution_trigger; pub use execution_trigger::ExecutionTrigger; pub mod execution_status; pub use execution_status::ExecutionStatus; +pub mod o_auth2_github_prompt; +pub use o_auth2_github_prompt::OAuth2GithubPrompt; +pub mod o_auth2_discord_prompt; +pub use o_auth2_discord_prompt::OAuth2DiscordPrompt; pub mod o_auth2_google_prompt; pub use o_auth2_google_prompt::OAuth2GooglePrompt; +pub mod o_auth2_zoho_prompt; +pub use o_auth2_zoho_prompt::OAuth2ZohoPrompt; +pub mod o_auth2_salesforce_prompt; +pub use o_auth2_salesforce_prompt::OAuth2SalesforcePrompt; +pub mod o_auth2_auth0_prompt; +pub use o_auth2_auth0_prompt::OAuth2Auth0Prompt; pub mod o_auth2_oidc_prompt; pub use o_auth2_oidc_prompt::OAuth2OidcPrompt; +pub mod o_auth2_okta_prompt; +pub use o_auth2_okta_prompt::OAuth2OktaPrompt; +pub mod o_auth2_microsoft_prompt; +pub use o_auth2_microsoft_prompt::OAuth2MicrosoftPrompt; +pub mod o_auth2_kakao_prompt; +pub use o_auth2_kakao_prompt::OAuth2KakaoPrompt; pub mod platform_type; pub use platform_type::PlatformType; pub mod proxy_rule_deployment_resource_type; @@ -130,3 +166,7 @@ pub mod message_status; pub use message_status::MessageStatus; pub mod billing_plan_group; pub use billing_plan_group::BillingPlanGroup; +pub mod domain_transfer_status_enum; +pub use domain_transfer_status_enum::DomainTransferStatusEnum; +pub mod waf_rule_action; +pub use waf_rule_action::WafRuleAction; diff --git a/src/enums/o_auth2_auth0_prompt.rs b/src/enums/o_auth2_auth0_prompt.rs new file mode 100644 index 0000000..62ef6d9 --- /dev/null +++ b/src/enums/o_auth2_auth0_prompt.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2Auth0Prompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "consent")] + Consent, +} + +impl OAuth2Auth0Prompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2Auth0Prompt::None => "none", + OAuth2Auth0Prompt::Login => "login", + OAuth2Auth0Prompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for OAuth2Auth0Prompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_discord_prompt.rs b/src/enums/o_auth2_discord_prompt.rs new file mode 100644 index 0000000..a05dd8a --- /dev/null +++ b/src/enums/o_auth2_discord_prompt.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2DiscordPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "consent")] + Consent, +} + +impl OAuth2DiscordPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2DiscordPrompt::None => "none", + OAuth2DiscordPrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for OAuth2DiscordPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_github_prompt.rs b/src/enums/o_auth2_github_prompt.rs new file mode 100644 index 0000000..5694abd --- /dev/null +++ b/src/enums/o_auth2_github_prompt.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2GithubPrompt { + #[serde(rename = "select_account")] + #[default] + SelectAccount, +} + +impl OAuth2GithubPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2GithubPrompt::SelectAccount => "select_account", + } + } +} + +impl std::fmt::Display for OAuth2GithubPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_kakao_prompt.rs b/src/enums/o_auth2_kakao_prompt.rs new file mode 100644 index 0000000..a6ca69f --- /dev/null +++ b/src/enums/o_auth2_kakao_prompt.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2KakaoPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "create")] + Create, + #[serde(rename = "select_account")] + SelectAccount, +} + +impl OAuth2KakaoPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2KakaoPrompt::None => "none", + OAuth2KakaoPrompt::Login => "login", + OAuth2KakaoPrompt::Create => "create", + OAuth2KakaoPrompt::SelectAccount => "select_account", + } + } +} + +impl std::fmt::Display for OAuth2KakaoPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_microsoft_prompt.rs b/src/enums/o_auth2_microsoft_prompt.rs new file mode 100644 index 0000000..dd3cdba --- /dev/null +++ b/src/enums/o_auth2_microsoft_prompt.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2MicrosoftPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "consent")] + Consent, + #[serde(rename = "select_account")] + SelectAccount, +} + +impl OAuth2MicrosoftPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2MicrosoftPrompt::None => "none", + OAuth2MicrosoftPrompt::Login => "login", + OAuth2MicrosoftPrompt::Consent => "consent", + OAuth2MicrosoftPrompt::SelectAccount => "select_account", + } + } +} + +impl std::fmt::Display for OAuth2MicrosoftPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_okta_prompt.rs b/src/enums/o_auth2_okta_prompt.rs new file mode 100644 index 0000000..749b9a9 --- /dev/null +++ b/src/enums/o_auth2_okta_prompt.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2OktaPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "consent")] + Consent, +} + +impl OAuth2OktaPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2OktaPrompt::None => "none", + OAuth2OktaPrompt::Login => "login", + OAuth2OktaPrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for OAuth2OktaPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_salesforce_prompt.rs b/src/enums/o_auth2_salesforce_prompt.rs new file mode 100644 index 0000000..2be8127 --- /dev/null +++ b/src/enums/o_auth2_salesforce_prompt.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2SalesforcePrompt { + #[serde(rename = "login")] + #[default] + Login, + #[serde(rename = "consent")] + Consent, +} + +impl OAuth2SalesforcePrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2SalesforcePrompt::Login => "login", + OAuth2SalesforcePrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for OAuth2SalesforcePrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth2_zoho_prompt.rs b/src/enums/o_auth2_zoho_prompt.rs new file mode 100644 index 0000000..4cf6e6f --- /dev/null +++ b/src/enums/o_auth2_zoho_prompt.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum OAuth2ZohoPrompt { + #[serde(rename = "consent")] + #[default] + Consent, +} + +impl OAuth2ZohoPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + OAuth2ZohoPrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for OAuth2ZohoPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/o_auth_provider.rs b/src/enums/o_auth_provider.rs index 19492a1..e930116 100644 --- a/src/enums/o_auth_provider.rs +++ b/src/enums/o_auth_provider.rs @@ -47,6 +47,8 @@ pub enum OAuthProvider { Google, #[serde(rename = "huggingface")] Huggingface, + #[serde(rename = "kakao")] + Kakao, #[serde(rename = "keycloak")] Keycloak, #[serde(rename = "kick")] @@ -77,12 +79,16 @@ pub enum OAuthProvider { Spotify, #[serde(rename = "stripe")] Stripe, + #[serde(rename = "tiktok")] + Tiktok, #[serde(rename = "tradeshift")] Tradeshift, #[serde(rename = "tradeshiftBox")] TradeshiftBox, #[serde(rename = "twitch")] Twitch, + #[serde(rename = "webflow")] + Webflow, #[serde(rename = "wordpress")] Wordpress, #[serde(rename = "x")] @@ -125,6 +131,7 @@ impl OAuthProvider { OAuthProvider::Gitlab => "gitlab", OAuthProvider::Google => "google", OAuthProvider::Huggingface => "huggingface", + OAuthProvider::Kakao => "kakao", OAuthProvider::Keycloak => "keycloak", OAuthProvider::Kick => "kick", OAuthProvider::Linkedin => "linkedin", @@ -140,9 +147,11 @@ impl OAuthProvider { OAuthProvider::Slack => "slack", OAuthProvider::Spotify => "spotify", OAuthProvider::Stripe => "stripe", + OAuthProvider::Tiktok => "tiktok", OAuthProvider::Tradeshift => "tradeshift", OAuthProvider::TradeshiftBox => "tradeshiftBox", OAuthProvider::Twitch => "twitch", + OAuthProvider::Webflow => "webflow", OAuthProvider::Wordpress => "wordpress", OAuthProvider::X => "x", OAuthProvider::Yahoo => "yahoo", diff --git a/src/enums/project_email_template_id.rs b/src/enums/project_email_template_id.rs index 51aa4c5..fd793a4 100644 --- a/src/enums/project_email_template_id.rs +++ b/src/enums/project_email_template_id.rs @@ -17,6 +17,10 @@ pub enum ProjectEmailTemplateId { SessionAlert, #[serde(rename = "otpSession")] OtpSession, + #[serde(rename = "otpVerification")] + OtpVerification, + #[serde(rename = "otpRecovery")] + OtpRecovery, } impl ProjectEmailTemplateId { @@ -30,6 +34,8 @@ impl ProjectEmailTemplateId { ProjectEmailTemplateId::MfaChallenge => "mfaChallenge", ProjectEmailTemplateId::SessionAlert => "sessionAlert", ProjectEmailTemplateId::OtpSession => "otpSession", + ProjectEmailTemplateId::OtpVerification => "otpVerification", + ProjectEmailTemplateId::OtpRecovery => "otpRecovery", } } } diff --git a/src/enums/project_key_scopes.rs b/src/enums/project_key_scopes.rs index a626a4b..133f976 100644 --- a/src/enums/project_key_scopes.rs +++ b/src/enums/project_key_scopes.rs @@ -183,6 +183,8 @@ pub enum ProjectKeyScopes { LocaleRead, #[serde(rename = "avatars.read")] AvatarsRead, + #[serde(rename = "avatars.write")] + AvatarsWrite, #[serde(rename = "health.read")] HealthRead, #[serde(rename = "assistant.read")] @@ -211,6 +213,8 @@ pub enum ProjectKeyScopes { PresencesRead, #[serde(rename = "presences.write")] PresencesWrite, + #[serde(rename = "dedicatedDatabases.execute")] + DedicatedDatabasesExecute, #[serde(rename = "backups.policies.read")] BackupsPoliciesRead, #[serde(rename = "backups.policies.write")] @@ -245,6 +249,10 @@ pub enum ProjectKeyScopes { Oauth2Write, #[serde(rename = "oauth2.introspect")] Oauth2Introspect, + #[serde(rename = "analytics.read")] + AnalyticsRead, + #[serde(rename = "analytics.write")] + AnalyticsWrite, } impl ProjectKeyScopes { @@ -341,6 +349,7 @@ impl ProjectKeyScopes { ProjectKeyScopes::WebhooksWrite => "webhooks.write", ProjectKeyScopes::LocaleRead => "locale.read", ProjectKeyScopes::AvatarsRead => "avatars.read", + ProjectKeyScopes::AvatarsWrite => "avatars.write", ProjectKeyScopes::HealthRead => "health.read", ProjectKeyScopes::AssistantRead => "assistant.read", ProjectKeyScopes::MigrationsRead => "migrations.read", @@ -355,6 +364,7 @@ impl ProjectKeyScopes { ProjectKeyScopes::ReportsWrite => "reports.write", ProjectKeyScopes::PresencesRead => "presences.read", ProjectKeyScopes::PresencesWrite => "presences.write", + ProjectKeyScopes::DedicatedDatabasesExecute => "dedicatedDatabases.execute", ProjectKeyScopes::BackupsPoliciesRead => "backups.policies.read", ProjectKeyScopes::BackupsPoliciesWrite => "backups.policies.write", ProjectKeyScopes::ArchivesRead => "archives.read", @@ -372,6 +382,8 @@ impl ProjectKeyScopes { ProjectKeyScopes::Oauth2Read => "oauth2.read", ProjectKeyScopes::Oauth2Write => "oauth2.write", ProjectKeyScopes::Oauth2Introspect => "oauth2.introspect", + ProjectKeyScopes::AnalyticsRead => "analytics.read", + ProjectKeyScopes::AnalyticsWrite => "analytics.write", } } } diff --git a/src/enums/project_o_auth2_auth0_prompt.rs b/src/enums/project_o_auth2_auth0_prompt.rs new file mode 100644 index 0000000..238aaba --- /dev/null +++ b/src/enums/project_o_auth2_auth0_prompt.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2Auth0Prompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "consent")] + Consent, +} + +impl ProjectOAuth2Auth0Prompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2Auth0Prompt::None => "none", + ProjectOAuth2Auth0Prompt::Login => "login", + ProjectOAuth2Auth0Prompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for ProjectOAuth2Auth0Prompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_discord_prompt.rs b/src/enums/project_o_auth2_discord_prompt.rs new file mode 100644 index 0000000..ed4fb69 --- /dev/null +++ b/src/enums/project_o_auth2_discord_prompt.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2DiscordPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "consent")] + Consent, +} + +impl ProjectOAuth2DiscordPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2DiscordPrompt::None => "none", + ProjectOAuth2DiscordPrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for ProjectOAuth2DiscordPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_git_hub_prompt.rs b/src/enums/project_o_auth2_git_hub_prompt.rs new file mode 100644 index 0000000..76c0193 --- /dev/null +++ b/src/enums/project_o_auth2_git_hub_prompt.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2GitHubPrompt { + #[serde(rename = "select_account")] + #[default] + SelectAccount, +} + +impl ProjectOAuth2GitHubPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2GitHubPrompt::SelectAccount => "select_account", + } + } +} + +impl std::fmt::Display for ProjectOAuth2GitHubPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_kakao_prompt.rs b/src/enums/project_o_auth2_kakao_prompt.rs new file mode 100644 index 0000000..1fb70b6 --- /dev/null +++ b/src/enums/project_o_auth2_kakao_prompt.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2KakaoPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "create")] + Create, + #[serde(rename = "select_account")] + SelectAccount, +} + +impl ProjectOAuth2KakaoPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2KakaoPrompt::None => "none", + ProjectOAuth2KakaoPrompt::Login => "login", + ProjectOAuth2KakaoPrompt::Create => "create", + ProjectOAuth2KakaoPrompt::SelectAccount => "select_account", + } + } +} + +impl std::fmt::Display for ProjectOAuth2KakaoPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_microsoft_prompt.rs b/src/enums/project_o_auth2_microsoft_prompt.rs new file mode 100644 index 0000000..9cc796c --- /dev/null +++ b/src/enums/project_o_auth2_microsoft_prompt.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2MicrosoftPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "consent")] + Consent, + #[serde(rename = "select_account")] + SelectAccount, +} + +impl ProjectOAuth2MicrosoftPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2MicrosoftPrompt::None => "none", + ProjectOAuth2MicrosoftPrompt::Login => "login", + ProjectOAuth2MicrosoftPrompt::Consent => "consent", + ProjectOAuth2MicrosoftPrompt::SelectAccount => "select_account", + } + } +} + +impl std::fmt::Display for ProjectOAuth2MicrosoftPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_okta_prompt.rs b/src/enums/project_o_auth2_okta_prompt.rs new file mode 100644 index 0000000..560f63c --- /dev/null +++ b/src/enums/project_o_auth2_okta_prompt.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2OktaPrompt { + #[serde(rename = "none")] + #[default] + None, + #[serde(rename = "login")] + Login, + #[serde(rename = "consent")] + Consent, +} + +impl ProjectOAuth2OktaPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2OktaPrompt::None => "none", + ProjectOAuth2OktaPrompt::Login => "login", + ProjectOAuth2OktaPrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for ProjectOAuth2OktaPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_salesforce_prompt.rs b/src/enums/project_o_auth2_salesforce_prompt.rs new file mode 100644 index 0000000..185367f --- /dev/null +++ b/src/enums/project_o_auth2_salesforce_prompt.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2SalesforcePrompt { + #[serde(rename = "login")] + #[default] + Login, + #[serde(rename = "consent")] + Consent, +} + +impl ProjectOAuth2SalesforcePrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2SalesforcePrompt::Login => "login", + ProjectOAuth2SalesforcePrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for ProjectOAuth2SalesforcePrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth2_zoho_prompt.rs b/src/enums/project_o_auth2_zoho_prompt.rs new file mode 100644 index 0000000..dfd1316 --- /dev/null +++ b/src/enums/project_o_auth2_zoho_prompt.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ProjectOAuth2ZohoPrompt { + #[serde(rename = "consent")] + #[default] + Consent, +} + +impl ProjectOAuth2ZohoPrompt { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ProjectOAuth2ZohoPrompt::Consent => "consent", + } + } +} + +impl std::fmt::Display for ProjectOAuth2ZohoPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/project_o_auth_provider_id.rs b/src/enums/project_o_auth_provider_id.rs index 619504c..167d270 100644 --- a/src/enums/project_o_auth_provider_id.rs +++ b/src/enums/project_o_auth_provider_id.rs @@ -47,6 +47,8 @@ pub enum ProjectOAuthProviderId { Google, #[serde(rename = "huggingface")] Huggingface, + #[serde(rename = "kakao")] + Kakao, #[serde(rename = "keycloak")] Keycloak, #[serde(rename = "kick")] @@ -77,12 +79,16 @@ pub enum ProjectOAuthProviderId { Spotify, #[serde(rename = "stripe")] Stripe, + #[serde(rename = "tiktok")] + Tiktok, #[serde(rename = "tradeshift")] Tradeshift, #[serde(rename = "tradeshiftBox")] TradeshiftBox, #[serde(rename = "twitch")] Twitch, + #[serde(rename = "webflow")] + Webflow, #[serde(rename = "wordpress")] Wordpress, #[serde(rename = "x")] @@ -125,6 +131,7 @@ impl ProjectOAuthProviderId { ProjectOAuthProviderId::Gitlab => "gitlab", ProjectOAuthProviderId::Google => "google", ProjectOAuthProviderId::Huggingface => "huggingface", + ProjectOAuthProviderId::Kakao => "kakao", ProjectOAuthProviderId::Keycloak => "keycloak", ProjectOAuthProviderId::Kick => "kick", ProjectOAuthProviderId::Linkedin => "linkedin", @@ -140,9 +147,11 @@ impl ProjectOAuthProviderId { ProjectOAuthProviderId::Slack => "slack", ProjectOAuthProviderId::Spotify => "spotify", ProjectOAuthProviderId::Stripe => "stripe", + ProjectOAuthProviderId::Tiktok => "tiktok", ProjectOAuthProviderId::Tradeshift => "tradeshift", ProjectOAuthProviderId::TradeshiftBox => "tradeshiftBox", ProjectOAuthProviderId::Twitch => "twitch", + ProjectOAuthProviderId::Webflow => "webflow", ProjectOAuthProviderId::Wordpress => "wordpress", ProjectOAuthProviderId::X => "x", ProjectOAuthProviderId::Yahoo => "yahoo", diff --git a/src/enums/project_policy_id.rs b/src/enums/project_policy_id.rs index 04b819e..48c2e0d 100644 --- a/src/enums/project_policy_id.rs +++ b/src/enums/project_policy_id.rs @@ -11,6 +11,10 @@ pub enum ProjectPolicyId { PasswordStrength, #[serde(rename = "password-personal-data")] PasswordPersonalData, + #[serde(rename = "password-pwned")] + PasswordPwned, + #[serde(rename = "password-rotation")] + PasswordRotation, #[serde(rename = "session-alert")] SessionAlert, #[serde(rename = "session-duration")] @@ -45,6 +49,8 @@ impl ProjectPolicyId { ProjectPolicyId::PasswordHistory => "password-history", ProjectPolicyId::PasswordStrength => "password-strength", ProjectPolicyId::PasswordPersonalData => "password-personal-data", + ProjectPolicyId::PasswordPwned => "password-pwned", + ProjectPolicyId::PasswordRotation => "password-rotation", ProjectPolicyId::SessionAlert => "session-alert", ProjectPolicyId::SessionDuration => "session-duration", ProjectPolicyId::SessionInvalidation => "session-invalidation", diff --git a/src/enums/proxy_rule_deployment_resource_type.rs b/src/enums/proxy_rule_deployment_resource_type.rs index 6f11d56..31b537f 100644 --- a/src/enums/proxy_rule_deployment_resource_type.rs +++ b/src/enums/proxy_rule_deployment_resource_type.rs @@ -7,6 +7,8 @@ pub enum ProxyRuleDeploymentResourceType { Function, #[serde(rename = "site")] Site, + #[serde(rename = "dedicatedDatabase")] + DedicatedDatabase, } impl ProxyRuleDeploymentResourceType { @@ -15,6 +17,7 @@ impl ProxyRuleDeploymentResourceType { match self { ProxyRuleDeploymentResourceType::Function => "function", ProxyRuleDeploymentResourceType::Site => "site", + ProxyRuleDeploymentResourceType::DedicatedDatabase => "dedicatedDatabase", } } } diff --git a/src/enums/runtime.rs b/src/enums/runtime.rs index cd554d8..9add86b 100644 --- a/src/enums/runtime.rs +++ b/src/enums/runtime.rs @@ -105,6 +105,8 @@ pub enum Runtime { Dart311, #[serde(rename = "dart-3.12")] Dart312, + #[serde(rename = "dart-3.13")] + Dart313, #[serde(rename = "dotnet-6.0")] Dotnet60, #[serde(rename = "dotnet-7.0")] @@ -189,6 +191,8 @@ pub enum Runtime { Flutter341, #[serde(rename = "flutter-3.44")] Flutter344, + #[serde(rename = "flutter-3.47")] + Flutter347, } impl Runtime { @@ -246,6 +250,7 @@ impl Runtime { Runtime::Dart310 => "dart-3.10", Runtime::Dart311 => "dart-3.11", Runtime::Dart312 => "dart-3.12", + Runtime::Dart313 => "dart-3.13", Runtime::Dotnet60 => "dotnet-6.0", Runtime::Dotnet70 => "dotnet-7.0", Runtime::Dotnet80 => "dotnet-8.0", @@ -288,6 +293,7 @@ impl Runtime { Runtime::Flutter338 => "flutter-3.38", Runtime::Flutter341 => "flutter-3.41", Runtime::Flutter344 => "flutter-3.44", + Runtime::Flutter347 => "flutter-3.47", } } } diff --git a/src/enums/tables_db_index_type.rs b/src/enums/tables_db_index_type.rs index c7f3f0d..fae92be 100644 --- a/src/enums/tables_db_index_type.rs +++ b/src/enums/tables_db_index_type.rs @@ -11,6 +11,8 @@ pub enum TablesDBIndexType { Unique, #[serde(rename = "spatial")] Spatial, + #[serde(rename = "trigram")] + Trigram, } impl TablesDBIndexType { @@ -21,6 +23,7 @@ impl TablesDBIndexType { TablesDBIndexType::Fulltext => "fulltext", TablesDBIndexType::Unique => "unique", TablesDBIndexType::Spatial => "spatial", + TablesDBIndexType::Trigram => "trigram", } } } diff --git a/src/enums/waf_rule_action.rs b/src/enums/waf_rule_action.rs new file mode 100644 index 0000000..2cbb999 --- /dev/null +++ b/src/enums/waf_rule_action.rs @@ -0,0 +1,35 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum WafRuleAction { + #[serde(rename = "bypass")] + #[default] + Bypass, + #[serde(rename = "deny")] + Deny, + #[serde(rename = "challenge")] + Challenge, + #[serde(rename = "rateLimit")] + RateLimit, + #[serde(rename = "redirect")] + Redirect, +} + +impl WafRuleAction { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + WafRuleAction::Bypass => "bypass", + WafRuleAction::Deny => "deny", + WafRuleAction::Challenge => "challenge", + WafRuleAction::RateLimit => "rateLimit", + WafRuleAction::Redirect => "redirect", + } + } +} + +impl std::fmt::Display for WafRuleAction { + 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 c28f974..25914d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```toml //! [dependencies] -//! appwrite = "0.18.0" +//! appwrite = "0.19.0" //! ``` //! //! ## Usage @@ -51,7 +51,7 @@ pub use input_file::InputFile; pub type Result = std::result::Result; /// SDK version -pub const VERSION: &str = "0.18.0"; +pub const VERSION: &str = "0.19.0"; /// SDK name pub const SDK_NAME: &str = "Rust"; diff --git a/src/models/account.rs b/src/models/account.rs new file mode 100644 index 0000000..6e09e69 --- /dev/null +++ b/src/models/account.rs @@ -0,0 +1,376 @@ +//! Account model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Account +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct Account { + /// 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, + /// 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")] + #[serde(skip_serializing_if = "Option::is_none")] + pub email_canonical: Option, + /// Whether the user email is from a free email provider. + #[serde(rename = "emailIsFree")] + #[serde(skip_serializing_if = "Option::is_none")] + pub email_is_free: Option, + /// Whether the user email is from a disposable email provider. + #[serde(rename = "emailIsDisposable")] + #[serde(skip_serializing_if = "Option::is_none")] + pub email_is_disposable: Option, + /// Whether the user email is from a corporate domain. + #[serde(rename = "emailIsCorporate")] + #[serde(skip_serializing_if = "Option::is_none")] + pub email_is_corporate: Option, + /// Whether the user email is in its canonical form. + #[serde(rename = "emailIsCanonical")] + #[serde(skip_serializing_if = "Option::is_none")] + pub email_is_canonical: Option, + /// Whether the password was found in a known data breach the last time it was + /// checked. Null when the password has never been checked. + #[serde(rename = "passwordPwned")] + #[serde(skip_serializing_if = "Option::is_none")] + 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")] + pub prefs: crate::models::Preferences, + /// 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")] + #[serde(skip_serializing_if = "Option::is_none")] + pub impersonator: Option, + /// ID of the original actor performing the impersonation. Present only when + /// the current request is impersonating another user. Internal audit logs + /// attribute the action to this user, while the impersonated target is + /// recorded only in internal audit payload data. + #[serde(rename = "impersonatorUserId")] + #[serde(skip_serializing_if = "Option::is_none")] + 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 Account { + /// 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 registration + pub fn registration(&self) -> &String { + &self.registration + } + + /// Get status + pub fn status(&self) -> &bool { + &self.status + } + + /// Get labels + pub fn labels(&self) -> &Vec { + &self.labels + } + + /// Get password_update + pub fn password_update(&self) -> &String { + &self.password_update + } + + /// Get email + pub fn email(&self) -> &String { + &self.email + } + + /// Get phone + pub fn phone(&self) -> &String { + &self.phone + } + + /// Get email_verification + pub fn email_verification(&self) -> &bool { + &self.email_verification + } + + /// Set email_canonical + pub fn set_email_canonical(mut self, email_canonical: String) -> Self { + self.email_canonical = Some(email_canonical); + self + } + + /// Get email_canonical + pub fn email_canonical(&self) -> Option<&String> { + self.email_canonical.as_ref() + } + + /// Set email_is_free + pub fn set_email_is_free(mut self, email_is_free: bool) -> Self { + self.email_is_free = Some(email_is_free); + self + } + + /// Get email_is_free + pub fn email_is_free(&self) -> Option<&bool> { + self.email_is_free.as_ref() + } + + /// Set email_is_disposable + pub fn set_email_is_disposable(mut self, email_is_disposable: bool) -> Self { + self.email_is_disposable = Some(email_is_disposable); + self + } + + /// Get email_is_disposable + pub fn email_is_disposable(&self) -> Option<&bool> { + self.email_is_disposable.as_ref() + } + + /// Set email_is_corporate + pub fn set_email_is_corporate(mut self, email_is_corporate: bool) -> Self { + self.email_is_corporate = Some(email_is_corporate); + self + } + + /// Get email_is_corporate + pub fn email_is_corporate(&self) -> Option<&bool> { + self.email_is_corporate.as_ref() + } + + /// Set email_is_canonical + pub fn set_email_is_canonical(mut self, email_is_canonical: bool) -> Self { + self.email_is_canonical = Some(email_is_canonical); + self + } + + /// Get email_is_canonical + pub fn email_is_canonical(&self) -> Option<&bool> { + self.email_is_canonical.as_ref() + } + + /// Set password_pwned + pub fn set_password_pwned(mut self, password_pwned: bool) -> Self { + self.password_pwned = Some(password_pwned); + self + } + + /// Get password_pwned + pub fn password_pwned(&self) -> Option<&bool> { + self.password_pwned.as_ref() + } + + /// Get phone_verification + pub fn phone_verification(&self) -> &bool { + &self.phone_verification + } + + /// Get mfa + pub fn mfa(&self) -> &bool { + &self.mfa + } + + /// Get prefs + pub fn prefs(&self) -> &crate::models::Preferences { + &self.prefs + } + + /// Get targets + pub fn targets(&self) -> &Vec { + &self.targets + } + + /// Get accessed_at + pub fn accessed_at(&self) -> &String { + &self.accessed_at + } + + /// Set impersonator + pub fn set_impersonator(mut self, impersonator: bool) -> Self { + self.impersonator = Some(impersonator); + self + } + + /// Get impersonator + pub fn impersonator(&self) -> Option<&bool> { + self.impersonator.as_ref() + } + + /// Set impersonator_user_id + pub fn set_impersonator_user_id(mut self, impersonator_user_id: String) -> Self { + self.impersonator_user_id = Some(impersonator_user_id); + self + } + + /// Get impersonator_user_id + pub fn impersonator_user_id(&self) -> Option<&String> { + self.impersonator_user_id.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_account_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.name(); + let _ = _model.registration(); + let _ = _model.status(); + let _ = _model.labels(); + let _ = _model.password_update(); + let _ = _model.email(); + let _ = _model.phone(); + let _ = _model.email_verification(); + let _ = _model.phone_verification(); + let _ = _model.mfa(); + let _ = _model.prefs(); + let _ = _model.targets(); + let _ = _model.accessed_at(); + } + + #[test] + fn test_account_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/billing_plan.rs b/src/models/billing_plan.rs index a7d82b7..936f3d8 100644 --- a/src/models/billing_plan.rs +++ b/src/models/billing_plan.rs @@ -46,6 +46,11 @@ pub struct BillingPlan { /// Maximum WAF rules per project #[serde(rename = "wafRules")] 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, /// Projects #[serde(rename = "projects")] pub projects: i64, @@ -154,6 +159,11 @@ pub struct BillingPlan { /// Does plan require billing address #[serde(rename = "requiresBillingAddress")] pub requires_billing_address: bool, + /// ISO country codes eligible for this regional plan. Empty means no + /// restriction. + #[serde(rename = "eligibleCountries")] + #[serde(skip_serializing_if = "Option::is_none")] + pub eligible_countries: Option>, /// Is the billing plan available #[serde(rename = "isAvailable")] pub is_available: bool, @@ -313,6 +323,17 @@ 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() + } + /// Get projects pub fn projects(&self) -> &i64 { &self.projects @@ -504,6 +525,17 @@ impl BillingPlan { &self.requires_billing_address } + /// Set eligible_countries + pub fn set_eligible_countries(mut self, eligible_countries: Vec) -> Self { + self.eligible_countries = Some(eligible_countries); + self + } + + /// Get eligible_countries + pub fn eligible_countries(&self) -> Option<&Vec> { + self.eligible_countries.as_ref() + } + /// Get is_available pub fn is_available(&self) -> &bool { &self.is_available diff --git a/src/models/dedicated_database.rs b/src/models/dedicated_database.rs index a380c5d..33e9d5c 100644 --- a/src/models/dedicated_database.rs +++ b/src/models/dedicated_database.rs @@ -95,6 +95,20 @@ pub struct DedicatedDatabase { /// Storage allocated in GB. #[serde(rename = "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, + /// 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, + /// Time the in-flight storage resize started, in ISO 8601 format. + #[serde(rename = "storageResizeStartedAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub storage_resize_started_at: Option, /// Storage class. Currently always 'ssd'; DigitalOcean exposes a single /// block-storage class. #[serde(rename = "storageClass")] @@ -321,6 +335,39 @@ 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 + } + + /// Get storage_target_gb + pub fn storage_target_gb(&self) -> Option<&i64> { + self.storage_target_gb.as_ref() + } + + /// Set storage_resize_started_at + pub fn set_storage_resize_started_at(mut self, storage_resize_started_at: String) -> Self { + self.storage_resize_started_at = Some(storage_resize_started_at); + self + } + + /// Get storage_resize_started_at + pub fn storage_resize_started_at(&self) -> Option<&String> { + self.storage_resize_started_at.as_ref() + } + /// Get storage_class pub fn storage_class(&self) -> &String { &self.storage_class diff --git a/src/models/dedicated_database_specification.rs b/src/models/dedicated_database_specification.rs index bc94463..7dab746 100644 --- a/src/models/dedicated_database_specification.rs +++ b/src/models/dedicated_database_specification.rs @@ -15,6 +15,22 @@ pub struct DedicatedDatabaseSpecification { /// Monthly price of the specification in USD. #[serde(rename = "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, + /// 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, + /// 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, + /// 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, /// Allocated CPU in millicores. #[serde(rename = "cpu")] pub cpu: i64, @@ -51,6 +67,50 @@ 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 + } + + /// 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 + } + + /// 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 + } + + /// Get pitr_rate + pub fn pitr_rate(&self) -> Option<&f64> { + self.pitr_rate.as_ref() + } + /// Get cpu pub fn cpu(&self) -> &i64 { &self.cpu diff --git a/src/models/dns_record.rs b/src/models/dns_record.rs new file mode 100644 index 0000000..b9dfab9 --- /dev/null +++ b/src/models/dns_record.rs @@ -0,0 +1,199 @@ +//! DnsRecord model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// DNSRecord +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DnsRecord { + /// DNS Record ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// DNS Record creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// DNS Record update date in ISO 8601 format. + #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] + pub updated_at: String, + /// DNS record type (e.g. A, CNAME, MX). + #[serde(rename = "type")] + #[serde(default = "default_type")] + pub r#type: String, + /// Record name or subdomain. + #[serde(rename = "name")] + #[serde(default = "default_name")] + pub name: String, + /// Value of the record (IP address, domain, etc.). + #[serde(rename = "value")] + #[serde(default = "default_value")] + pub value: String, + /// Time to live (in seconds). + #[serde(rename = "ttl")] + #[serde(default = "default_ttl")] + pub ttl: i64, + /// Record priority (commonly used for MX). + #[serde(rename = "priority")] + #[serde(default = "default_priority")] + pub priority: i64, + /// Whether this record is locked (read-only). + #[serde(rename = "lock")] + #[serde(default = "default_lock")] + pub lock: bool, + /// Record weight (used for SRV records). + #[serde(rename = "weight")] + #[serde(default = "default_weight")] + pub weight: i64, + /// Target port (used for SRV records). + #[serde(rename = "port")] + #[serde(default = "default_port")] + pub port: i64, + /// Comment for the DNS record. + #[serde(rename = "comment")] + #[serde(default = "default_comment")] + pub comment: 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_name() -> String { + "".to_string() +} + +fn default_value() -> String { + "".to_string() +} + +fn default_ttl() -> i64 { + 3600 +} + +fn default_priority() -> i64 { + 0 +} + +fn default_lock() -> bool { + false +} + +fn default_weight() -> i64 { + 0 +} + +fn default_port() -> i64 { + 0 +} + +fn default_comment() -> String { + "".to_string() +} + +impl DnsRecord { + /// 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 r#type + pub fn r#type(&self) -> &String { + &self.r#type + } + + /// Get name + pub fn name(&self) -> &String { + &self.name + } + + /// Get value + pub fn value(&self) -> &String { + &self.value + } + + /// Get ttl + pub fn ttl(&self) -> &i64 { + &self.ttl + } + + /// Get priority + pub fn priority(&self) -> &i64 { + &self.priority + } + + /// Get lock + pub fn lock(&self) -> &bool { + &self.lock + } + + /// Get weight + pub fn weight(&self) -> &i64 { + &self.weight + } + + /// Get port + pub fn port(&self) -> &i64 { + &self.port + } + + /// Get comment + pub fn comment(&self) -> &String { + &self.comment + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dns_record_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.r#type(); + let _ = _model.name(); + let _ = _model.value(); + let _ = _model.ttl(); + let _ = _model.priority(); + let _ = _model.lock(); + let _ = _model.weight(); + let _ = _model.port(); + let _ = _model.comment(); + } + + #[test] + fn test_dns_record_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/dns_records_list.rs b/src/models/dns_records_list.rs new file mode 100644 index 0000000..56d5c9d --- /dev/null +++ b/src/models/dns_records_list.rs @@ -0,0 +1,59 @@ +//! DnsRecordsList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// DNS records list +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DnsRecordsList { + /// Total number of dnsRecords that matched your query. + #[serde(rename = "total")] + #[serde(default = "default_total")] + pub total: i64, + /// List of dnsRecords. + #[serde(rename = "dnsRecords")] + #[serde(default = "default_dns_records")] + pub dns_records: Vec, +} + +fn default_total() -> i64 { + 0 +} + +fn default_dns_records() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +impl DnsRecordsList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get dns_records + pub fn dns_records(&self) -> &Vec { + &self.dns_records + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dns_records_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.dns_records(); + } + + #[test] + fn test_dns_records_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/domain.rs b/src/models/domain.rs new file mode 100644 index 0000000..c391eca --- /dev/null +++ b/src/models/domain.rs @@ -0,0 +1,218 @@ +//! Domain model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Domain +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct Domain { + /// Domain ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// Domain creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// Domain 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, + /// Domain registrar (e.g. "appwrite" or "third_party"). + #[serde(rename = "registrar")] + #[serde(default = "default_registrar")] + pub registrar: String, + /// Nameservers setting. "Appwrite" or empty string. + #[serde(rename = "nameservers")] + #[serde(default = "default_nameservers")] + pub nameservers: String, + /// Domain expiry date in ISO 8601 format. + #[serde(rename = "expire")] + #[serde(default = "default_expire")] + pub expire: String, + /// Domain renewal date in ISO 8601 format. + #[serde(rename = "renewal")] + #[serde(default = "default_renewal")] + pub renewal: String, + /// If set to true, the domain will automatically renew. + #[serde(rename = "autoRenewal")] + #[serde(default = "default_auto_renewal")] + pub auto_renewal: bool, + /// Renewal price (in cents). + #[serde(rename = "renewalPrice")] + #[serde(default = "default_renewal_price")] + pub renewal_price: i64, + /// Transfer status for domains being transferred in. Null when the domain is + /// not being transferred. + #[serde(rename = "transferStatus")] + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_status: Option, + /// Team ID. + #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] + pub team_id: String, + /// Dns records + #[serde(rename = "dnsRecords")] + #[serde(default = "default_dns_records")] + pub dns_records: Vec, +} + +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_registrar() -> String { + "".to_string() +} + +fn default_nameservers() -> String { + "".to_string() +} + +fn default_expire() -> String { + "".to_string() +} + +fn default_renewal() -> String { + "".to_string() +} + +fn default_auto_renewal() -> bool { + false +} + +fn default_renewal_price() -> i64 { + 0 +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_dns_records() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +impl Domain { + /// 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 domain + pub fn domain(&self) -> &String { + &self.domain + } + + /// Get registrar + pub fn registrar(&self) -> &String { + &self.registrar + } + + /// Get nameservers + pub fn nameservers(&self) -> &String { + &self.nameservers + } + + /// Get expire + pub fn expire(&self) -> &String { + &self.expire + } + + /// Get renewal + pub fn renewal(&self) -> &String { + &self.renewal + } + + /// Get auto_renewal + pub fn auto_renewal(&self) -> &bool { + &self.auto_renewal + } + + /// Get renewal_price + pub fn renewal_price(&self) -> &i64 { + &self.renewal_price + } + + /// Set transfer_status + pub fn set_transfer_status( + mut self, + transfer_status: crate::enums::DomainTransferStatusEnum, + ) -> Self { + self.transfer_status = Some(transfer_status); + self + } + + /// Get transfer_status + pub fn transfer_status(&self) -> Option<&crate::enums::DomainTransferStatusEnum> { + self.transfer_status.as_ref() + } + + /// Get team_id + pub fn team_id(&self) -> &String { + &self.team_id + } + + /// Get dns_records + pub fn dns_records(&self) -> &Vec { + &self.dns_records + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_domain_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.domain(); + let _ = _model.registrar(); + let _ = _model.nameservers(); + let _ = _model.expire(); + let _ = _model.renewal(); + let _ = _model.auto_renewal(); + let _ = _model.renewal_price(); + let _ = _model.team_id(); + let _ = _model.dns_records(); + } + + #[test] + fn test_domain_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/domain_price.rs b/src/models/domain_price.rs new file mode 100644 index 0000000..16c5a30 --- /dev/null +++ b/src/models/domain_price.rs @@ -0,0 +1,147 @@ +//! DomainPrice model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// DomainPrice +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DomainPrice { + /// Domain name. + #[serde(rename = "domain")] + #[serde(default = "default_domain")] + pub domain: String, + /// Top-level domain for the requested domain. + #[serde(rename = "tld")] + #[serde(default = "default_tld")] + pub tld: String, + /// Whether the domain is currently available for registration. + #[serde(rename = "available")] + #[serde(default = "default_available")] + pub available: bool, + /// Domain registration price. Null when the price could not be resolved, for + /// example for an unsupported TLD. + #[serde(rename = "price")] + #[serde(skip_serializing_if = "Option::is_none")] + pub price: Option, + /// Price period in years. + #[serde(rename = "periodYears")] + #[serde(default = "default_period_years")] + pub period_years: i64, + /// Whether the domain is a premium domain. + #[serde(rename = "premium")] + #[serde(default = "default_premium")] + pub premium: bool, + /// Domain renewal price for the same period. Null when the domain was not + /// priced or the registrar has no renewal price for it. + #[serde(rename = "renewalPrice")] + #[serde(skip_serializing_if = "Option::is_none")] + pub renewal_price: Option, + /// Renewal price period in years. + #[serde(rename = "renewalPeriodYears")] + #[serde(default = "default_renewal_period_years")] + pub renewal_period_years: i64, +} + +fn default_domain() -> String { + "".to_string() +} + +fn default_tld() -> String { + "".to_string() +} + +fn default_available() -> bool { + false +} + +fn default_period_years() -> i64 { + 1 +} + +fn default_premium() -> bool { + false +} + +fn default_renewal_period_years() -> i64 { + 1 +} + +impl DomainPrice { + /// Get domain + pub fn domain(&self) -> &String { + &self.domain + } + + /// Get tld + pub fn tld(&self) -> &String { + &self.tld + } + + /// Get available + pub fn available(&self) -> &bool { + &self.available + } + + /// Set price + pub fn set_price(mut self, price: f64) -> Self { + self.price = Some(price); + self + } + + /// Get price + pub fn price(&self) -> Option<&f64> { + self.price.as_ref() + } + + /// Get period_years + pub fn period_years(&self) -> &i64 { + &self.period_years + } + + /// Get premium + pub fn premium(&self) -> &bool { + &self.premium + } + + /// Set renewal_price + pub fn set_renewal_price(mut self, renewal_price: f64) -> Self { + self.renewal_price = Some(renewal_price); + self + } + + /// Get renewal_price + pub fn renewal_price(&self) -> Option<&f64> { + self.renewal_price.as_ref() + } + + /// Get renewal_period_years + pub fn renewal_period_years(&self) -> &i64 { + &self.renewal_period_years + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_domain_price_creation() { + let _model = ::default(); + let _ = _model.domain(); + let _ = _model.tld(); + let _ = _model.available(); + let _ = _model.period_years(); + let _ = _model.premium(); + let _ = _model.renewal_period_years(); + } + + #[test] + fn test_domain_price_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/domain_prices_list.rs b/src/models/domain_prices_list.rs new file mode 100644 index 0000000..9e9b187 --- /dev/null +++ b/src/models/domain_prices_list.rs @@ -0,0 +1,59 @@ +//! DomainPricesList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Domain prices list +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DomainPricesList { + /// Total number of prices that matched your query. + #[serde(rename = "total")] + #[serde(default = "default_total")] + pub total: i64, + /// List of prices. + #[serde(rename = "prices")] + #[serde(default = "default_prices")] + pub prices: Vec, +} + +fn default_total() -> i64 { + 0 +} + +fn default_prices() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +impl DomainPricesList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get prices + pub fn prices(&self) -> &Vec { + &self.prices + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_domain_prices_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.prices(); + } + + #[test] + fn test_domain_prices_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/domain_transfer_status.rs b/src/models/domain_transfer_status.rs new file mode 100644 index 0000000..74dec3d --- /dev/null +++ b/src/models/domain_transfer_status.rs @@ -0,0 +1,73 @@ +//! DomainTransferStatus model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// domainTransferStatus +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DomainTransferStatus { + /// Transfer status. + #[serde(rename = "status")] + #[serde(default = "default_status")] + pub status: crate::enums::DomainTransferStatusEnum, + /// Additional transfer status information. + #[serde(rename = "reason")] + #[serde(default = "default_reason")] + pub reason: String, + /// Transfer status timestamp in ISO 8601 format. + #[serde(rename = "timestamp")] + #[serde(default = "default_timestamp")] + pub timestamp: String, +} + +fn default_status() -> crate::enums::DomainTransferStatusEnum { + serde_json::from_value(serde_json::json!("pending_registry")).unwrap() +} + +fn default_reason() -> String { + "".to_string() +} + +fn default_timestamp() -> String { + "".to_string() +} + +impl DomainTransferStatus { + /// Get status + pub fn status(&self) -> &crate::enums::DomainTransferStatusEnum { + &self.status + } + + /// Get reason + pub fn reason(&self) -> &String { + &self.reason + } + + /// Get timestamp + pub fn timestamp(&self) -> &String { + &self.timestamp + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_domain_transfer_status_creation() { + let _model = ::default(); + let _ = _model.status(); + let _ = _model.reason(); + let _ = _model.timestamp(); + } + + #[test] + fn test_domain_transfer_status_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/domains_list.rs b/src/models/domains_list.rs new file mode 100644 index 0000000..fc7b5dd --- /dev/null +++ b/src/models/domains_list.rs @@ -0,0 +1,59 @@ +//! DomainsList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Domains list +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DomainsList { + /// Total number of domains that matched your query. + #[serde(rename = "total")] + #[serde(default = "default_total")] + pub total: i64, + /// List of domains. + #[serde(rename = "domains")] + #[serde(default = "default_domains")] + pub domains: Vec, +} + +fn default_total() -> i64 { + 0 +} + +fn default_domains() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +impl DomainsList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get domains + pub fn domains(&self) -> &Vec { + &self.domains + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_domains_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.domains(); + } + + #[test] + fn test_domains_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/identity.rs b/src/models/identity.rs index 841a5ab..aca8541 100644 --- a/src/models/identity.rs +++ b/src/models/identity.rs @@ -36,6 +36,11 @@ pub struct Identity { /// Identity Provider Refresh Token. #[serde(rename = "providerRefreshToken")] 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, } impl Identity { @@ -88,6 +93,17 @@ impl Identity { pub fn provider_refresh_token(&self) -> &String { &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() + } } #[cfg(test)] diff --git a/src/models/mod.rs b/src/models/mod.rs index 2a0de42..8c4e935 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -214,6 +214,8 @@ pub mod algo_scrypt_modified; pub use algo_scrypt_modified::AlgoScryptModified; pub mod algo_argon2; pub use algo_argon2::AlgoArgon2; +pub mod account; +pub use account::Account; pub mod preferences; pub use preferences::Preferences; pub mod session; @@ -300,6 +302,8 @@ pub mod o_auth2_x; pub use o_auth2_x::OAuth2X; pub mod o_auth2_word_press; pub use o_auth2_word_press::OAuth2WordPress; +pub mod o_auth2_webflow; +pub use o_auth2_webflow::OAuth2Webflow; pub mod o_auth2_twitch; pub use o_auth2_twitch::OAuth2Twitch; pub mod o_auth2_stripe; @@ -358,6 +362,10 @@ pub mod o_auth2_microsoft; pub use o_auth2_microsoft::OAuth2Microsoft; pub mod o_auth2_resend; pub use o_auth2_resend::OAuth2Resend; +pub mod o_auth2_tik_tok; +pub use o_auth2_tik_tok::OAuth2TikTok; +pub mod o_auth2_kakao; +pub use o_auth2_kakao::OAuth2Kakao; pub mod o_auth2_provider_list; pub use o_auth2_provider_list::OAuth2ProviderList; pub mod policy_password_dictionary; @@ -368,6 +376,10 @@ pub mod policy_password_strength; pub use policy_password_strength::PolicyPasswordStrength; pub mod policy_password_personal_data; pub use policy_password_personal_data::PolicyPasswordPersonalData; +pub mod policy_password_pwned; +pub use policy_password_pwned::PolicyPasswordPwned; +pub mod policy_password_rotation; +pub use policy_password_rotation::PolicyPasswordRotation; pub mod policy_session_alert; pub use policy_session_alert::PolicySessionAlert; pub mod policy_session_duration; @@ -496,6 +508,14 @@ pub mod dedicated_database_restoration; pub use dedicated_database_restoration::DedicatedDatabaseRestoration; pub mod database_status; pub use database_status::DatabaseStatus; +pub mod dns_record; +pub use dns_record::DnsRecord; +pub mod domain; +pub use domain::Domain; +pub mod domain_price; +pub use domain_price::DomainPrice; +pub mod domain_transfer_status; +pub use domain_transfer_status::DomainTransferStatus; pub mod dedicated_database_extensions; pub use dedicated_database_extensions::DedicatedDatabaseExtensions; pub mod dedicated_database_member; @@ -572,10 +592,24 @@ pub mod oauth2_par; pub use oauth2_par::Oauth2PAR; pub mod oauth2_token; pub use oauth2_token::Oauth2Token; +pub mod oauth2_introspection; +pub use oauth2_introspection::Oauth2Introspection; pub mod oauth2_consent; pub use oauth2_consent::Oauth2Consent; pub mod oauth2_consent_token; pub use oauth2_consent_token::Oauth2ConsentToken; +pub mod waf_rule_bypass; +pub use waf_rule_bypass::WafRuleBypass; +pub mod waf_rule_deny; +pub use waf_rule_deny::WafRuleDeny; +pub mod waf_rule_challenge; +pub use waf_rule_challenge::WafRuleChallenge; +pub mod waf_rule_rate_limit; +pub use waf_rule_rate_limit::WafRuleRateLimit; +pub mod waf_rule_redirect; +pub use waf_rule_redirect::WafRuleRedirect; +pub mod waf_rule_list; +pub use waf_rule_list::WafRuleList; pub mod oauth2_project; pub use oauth2_project::Oauth2Project; pub mod oauth2_organization; @@ -600,6 +634,12 @@ pub mod database_migration_list; pub use database_migration_list::DatabaseMigrationList; pub mod dedicated_database_list; pub use dedicated_database_list::DedicatedDatabaseList; +pub mod dns_records_list; +pub use dns_records_list::DnsRecordsList; +pub mod domain_prices_list; +pub use domain_prices_list::DomainPricesList; +pub mod domains_list; +pub use domains_list::DomainsList; pub mod apps_list; pub use apps_list::AppsList; pub mod app_secret_list; @@ -725,6 +765,7 @@ impl Model for AlgoBcrypt {} impl Model for AlgoScrypt {} impl Model for AlgoScryptModified {} impl Model for AlgoArgon2 {} +impl Model for Account {} impl Model for Preferences {} impl Model for Session {} impl Model for Identity {} @@ -768,6 +809,7 @@ impl Model for OAuth2Zoho {} impl Model for OAuth2Yandex {} impl Model for OAuth2X {} impl Model for OAuth2WordPress {} +impl Model for OAuth2Webflow {} impl Model for OAuth2Twitch {} impl Model for OAuth2Stripe {} impl Model for OAuth2Spotify {} @@ -797,11 +839,15 @@ impl Model for OAuth2Kick {} impl Model for OAuth2Apple {} impl Model for OAuth2Microsoft {} impl Model for OAuth2Resend {} +impl Model for OAuth2TikTok {} +impl Model for OAuth2Kakao {} impl Model for OAuth2ProviderList {} impl Model for PolicyPasswordDictionary {} impl Model for PolicyPasswordHistory {} impl Model for PolicyPasswordStrength {} impl Model for PolicyPasswordPersonalData {} +impl Model for PolicyPasswordPwned {} +impl Model for PolicyPasswordRotation {} impl Model for PolicySessionAlert {} impl Model for PolicySessionDuration {} impl Model for PolicySessionInvalidation {} @@ -866,6 +912,10 @@ impl Model for DedicatedDatabaseExecution {} impl Model for DedicatedDatabaseExecutionColumn {} impl Model for DedicatedDatabaseRestoration {} impl Model for DatabaseStatus {} +impl Model for DnsRecord {} +impl Model for Domain {} +impl Model for DomainPrice {} +impl Model for DomainTransferStatus {} impl Model for DedicatedDatabaseExtensions {} impl Model for DedicatedDatabaseMember {} impl Model for DedicatedDatabaseOperation {} @@ -904,8 +954,15 @@ impl Model for Oauth2Grant {} impl Model for Oauth2DeviceAuthorization {} impl Model for Oauth2PAR {} impl Model for Oauth2Token {} +impl Model for Oauth2Introspection {} impl Model for Oauth2Consent {} impl Model for Oauth2ConsentToken {} +impl Model for WafRuleBypass {} +impl Model for WafRuleDeny {} +impl Model for WafRuleChallenge {} +impl Model for WafRuleRateLimit {} +impl Model for WafRuleRedirect {} +impl Model for WafRuleList {} impl Model for Oauth2Project {} impl Model for Oauth2Organization {} impl Model for Oauth2ProjectList {} @@ -918,6 +975,9 @@ impl Model for BackupPolicyList {} impl Model for BackupRestorationList {} impl Model for DatabaseMigrationList {} impl Model for DedicatedDatabaseList {} +impl Model for DnsRecordsList {} +impl Model for DomainPricesList {} +impl Model for DomainsList {} impl Model for AppsList {} impl Model for AppSecretList {} impl Model for AppScopeList {} diff --git a/src/models/o_auth2_apple.rs b/src/models/o_auth2_apple.rs index 47a2616..5022915 100644 --- a/src/models/o_auth2_apple.rs +++ b/src/models/o_auth2_apple.rs @@ -25,6 +25,17 @@ pub struct OAuth2Apple { /// PEM markers is 200 characters long. #[serde(rename = "p8File")] 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, + /// 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>, } impl OAuth2Apple { @@ -57,6 +68,28 @@ impl OAuth2Apple { pub fn p8_file(&self) -> &String { &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 + } + + /// Get native_client_ids + pub fn native_client_ids(&self) -> Option<&Vec> { + self.native_client_ids.as_ref() + } } #[cfg(test)] diff --git a/src/models/o_auth2_auth0.rs b/src/models/o_auth2_auth0.rs index 0242284..12a3426 100644 --- a/src/models/o_auth2_auth0.rs +++ b/src/models/o_auth2_auth0.rs @@ -18,6 +18,10 @@ pub struct OAuth2Auth0 { /// Auth0 OAuth2 client secret. #[serde(rename = "clientSecret")] pub client_secret: String, + /// Auth0 OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, /// Auth0 OAuth2 endpoint domain. #[serde(rename = "endpoint")] pub endpoint: String, @@ -44,6 +48,17 @@ 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() + } + /// Get endpoint pub fn endpoint(&self) -> &String { &self.endpoint diff --git a/src/models/o_auth2_discord.rs b/src/models/o_auth2_discord.rs index 0f24f6e..91a601b 100644 --- a/src/models/o_auth2_discord.rs +++ b/src/models/o_auth2_discord.rs @@ -18,6 +18,10 @@ pub struct OAuth2Discord { /// Discord OAuth2 client secret. #[serde(rename = "clientSecret")] pub client_secret: String, + /// Discord OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, } impl OAuth2Discord { @@ -40,6 +44,17 @@ impl OAuth2Discord { pub fn client_secret(&self) -> &String { &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() + } } #[cfg(test)] diff --git a/src/models/o_auth2_github.rs b/src/models/o_auth2_github.rs index 34d2137..1be7953 100644 --- a/src/models/o_auth2_github.rs +++ b/src/models/o_auth2_github.rs @@ -19,6 +19,10 @@ pub struct OAuth2Github { /// GitHub OAuth2 client secret. #[serde(rename = "clientSecret")] pub client_secret: String, + /// GitHub OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, } impl OAuth2Github { @@ -41,6 +45,17 @@ impl OAuth2Github { pub fn client_secret(&self) -> &String { &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() + } } #[cfg(test)] diff --git a/src/models/o_auth2_google.rs b/src/models/o_auth2_google.rs index 0fcb39b..ece34e2 100644 --- a/src/models/o_auth2_google.rs +++ b/src/models/o_auth2_google.rs @@ -21,6 +21,17 @@ pub struct OAuth2Google { /// Google OAuth2 prompt values. #[serde(rename = "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, + /// 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>, } impl OAuth2Google { @@ -48,6 +59,28 @@ impl OAuth2Google { pub fn prompt(&self) -> &Vec { &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 + } + + /// Get native_client_ids + pub fn native_client_ids(&self) -> Option<&Vec> { + self.native_client_ids.as_ref() + } } #[cfg(test)] diff --git a/src/models/o_auth2_kakao.rs b/src/models/o_auth2_kakao.rs new file mode 100644 index 0000000..15d92a4 --- /dev/null +++ b/src/models/o_auth2_kakao.rs @@ -0,0 +1,101 @@ +//! OAuth2Kakao model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// OAuth2Kakao +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct OAuth2Kakao { + /// 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, + /// Kakao OAuth2 REST API key. + #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] + pub client_id: String, + /// Kakao OAuth2 client secret. + #[serde(rename = "clientSecret")] + #[serde(default = "default_client_secret")] + pub client_secret: String, + /// Kakao OAuth2 prompt values. + #[serde(rename = "prompt")] + #[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 OAuth2Kakao { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get client_id + pub fn client_id(&self) -> &String { + &self.client_id + } + + /// Get client_secret + pub fn client_secret(&self) -> &String { + &self.client_secret + } + + /// Get prompt + pub fn prompt(&self) -> &Vec { + &self.prompt + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_o_auth2_kakao_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.enabled(); + let _ = _model.client_id(); + let _ = _model.client_secret(); + let _ = _model.prompt(); + } + + #[test] + fn test_o_auth2_kakao_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/o_auth2_microsoft.rs b/src/models/o_auth2_microsoft.rs index b871f19..3a2535b 100644 --- a/src/models/o_auth2_microsoft.rs +++ b/src/models/o_auth2_microsoft.rs @@ -18,6 +18,10 @@ pub struct OAuth2Microsoft { /// Microsoft OAuth2 application secret. #[serde(rename = "applicationSecret")] pub application_secret: String, + /// Microsoft OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, /// Microsoft Entra ID tenant identifier. Use 'common', 'organizations', /// 'consumers' or a specific tenant ID. #[serde(rename = "tenant")] @@ -45,6 +49,17 @@ 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() + } + /// Get tenant pub fn tenant(&self) -> &String { &self.tenant diff --git a/src/models/o_auth2_okta.rs b/src/models/o_auth2_okta.rs index 1c217d7..e8fdf00 100644 --- a/src/models/o_auth2_okta.rs +++ b/src/models/o_auth2_okta.rs @@ -18,6 +18,10 @@ pub struct OAuth2Okta { /// Okta OAuth2 client secret. #[serde(rename = "clientSecret")] pub client_secret: String, + /// Okta OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, /// Okta OAuth2 domain. #[serde(rename = "domain")] pub domain: String, @@ -47,6 +51,17 @@ 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() + } + /// Get domain pub fn domain(&self) -> &String { &self.domain diff --git a/src/models/o_auth2_salesforce.rs b/src/models/o_auth2_salesforce.rs index cfcbf76..4565047 100644 --- a/src/models/o_auth2_salesforce.rs +++ b/src/models/o_auth2_salesforce.rs @@ -18,6 +18,10 @@ pub struct OAuth2Salesforce { /// Salesforce OAuth2 consumer secret. #[serde(rename = "customerSecret")] pub customer_secret: String, + /// Salesforce OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, } impl OAuth2Salesforce { @@ -40,6 +44,17 @@ impl OAuth2Salesforce { pub fn customer_secret(&self) -> &String { &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() + } } #[cfg(test)] diff --git a/src/models/o_auth2_tik_tok.rs b/src/models/o_auth2_tik_tok.rs new file mode 100644 index 0000000..61b966f --- /dev/null +++ b/src/models/o_auth2_tik_tok.rs @@ -0,0 +1,87 @@ +//! OAuth2TikTok model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// OAuth2TikTok +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct OAuth2TikTok { + /// 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, + /// TikTok OAuth2 client key. + #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] + pub client_id: String, + /// TikTok 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 OAuth2TikTok { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get client_id + pub fn client_id(&self) -> &String { + &self.client_id + } + + /// Get client_secret + pub fn client_secret(&self) -> &String { + &self.client_secret + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_o_auth2_tik_tok_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.enabled(); + let _ = _model.client_id(); + let _ = _model.client_secret(); + } + + #[test] + fn test_o_auth2_tik_tok_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/o_auth2_webflow.rs b/src/models/o_auth2_webflow.rs new file mode 100644 index 0000000..8a866ab --- /dev/null +++ b/src/models/o_auth2_webflow.rs @@ -0,0 +1,87 @@ +//! OAuth2Webflow model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// OAuth2Webflow +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct OAuth2Webflow { + /// 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, + /// Webflow OAuth2 client ID. + #[serde(rename = "clientId")] + #[serde(default = "default_client_id")] + pub client_id: String, + /// Webflow 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 OAuth2Webflow { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get client_id + pub fn client_id(&self) -> &String { + &self.client_id + } + + /// Get client_secret + pub fn client_secret(&self) -> &String { + &self.client_secret + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_o_auth2_webflow_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.enabled(); + let _ = _model.client_id(); + let _ = _model.client_secret(); + } + + #[test] + fn test_o_auth2_webflow_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/o_auth2_zoho.rs b/src/models/o_auth2_zoho.rs index e0fc894..58cef47 100644 --- a/src/models/o_auth2_zoho.rs +++ b/src/models/o_auth2_zoho.rs @@ -18,6 +18,10 @@ pub struct OAuth2Zoho { /// Zoho OAuth2 client secret. #[serde(rename = "clientSecret")] pub client_secret: String, + /// Zoho OAuth2 prompt values. + #[serde(rename = "prompt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub prompt: Option>, } impl OAuth2Zoho { @@ -40,6 +44,17 @@ impl OAuth2Zoho { pub fn client_secret(&self) -> &String { &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() + } } #[cfg(test)] diff --git a/src/models/oauth2_introspection.rs b/src/models/oauth2_introspection.rs new file mode 100644 index 0000000..d252875 --- /dev/null +++ b/src/models/oauth2_introspection.rs @@ -0,0 +1,218 @@ +//! Oauth2Introspection model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// OAuth2 Introspection +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct Oauth2Introspection { + /// Whether the token is currently active. An inactive token carries no other + /// claims (RFC 7662). + #[serde(rename = "active")] + #[serde(default = "default_active")] + pub active: bool, + /// Kind of token that was introspected. Can be one of: `access_token` or + /// `refresh_token`. + #[serde(rename = "token_use")] + #[serde(skip_serializing_if = "Option::is_none")] + pub token_use: Option, + /// OAuth2 token type. + #[serde(rename = "token_type")] + #[serde(skip_serializing_if = "Option::is_none")] + pub token_type: Option, + /// Space-separated scopes granted to the token. + #[serde(rename = "scope")] + #[serde(skip_serializing_if = "Option::is_none")] + pub scope: Option, + /// OAuth2 client ID the token was issued to. + #[serde(rename = "client_id")] + #[serde(skip_serializing_if = "Option::is_none")] + pub client_id: Option, + /// ID of the user who authorized the token. + #[serde(rename = "sub")] + #[serde(skip_serializing_if = "Option::is_none")] + pub sub: Option, + /// Audiences the token is intended for. The first entry is the project API + /// base URL; any further entries are the resource indicators requested at + /// authorization time (RFC 8707). + #[serde(rename = "aud")] + #[serde(skip_serializing_if = "Option::is_none")] + pub aud: Option>, + /// Issuer URL of the token. + #[serde(rename = "iss")] + #[serde(skip_serializing_if = "Option::is_none")] + pub iss: Option, + /// Expiration time as a Unix timestamp in seconds. + #[serde(rename = "exp")] + #[serde(skip_serializing_if = "Option::is_none")] + pub exp: Option, + /// Issued-at time as a Unix timestamp in seconds. + #[serde(rename = "iat")] + #[serde(skip_serializing_if = "Option::is_none")] + pub iat: Option, + /// Unique identifier of the token. + #[serde(rename = "jti")] + #[serde(skip_serializing_if = "Option::is_none")] + pub jti: Option, + /// Granted RFC 9396 authorization details, restricted to what the user can + /// currently access. + #[serde(rename = "authorization_details")] + #[serde(skip_serializing_if = "Option::is_none")] + pub authorization_details: Option>, +} + +fn default_active() -> bool { + false +} + +impl Oauth2Introspection { + /// Get active + pub fn active(&self) -> &bool { + &self.active + } + + /// Set token_use + pub fn set_token_use(mut self, token_use: String) -> Self { + self.token_use = Some(token_use); + self + } + + /// Get token_use + pub fn token_use(&self) -> Option<&String> { + self.token_use.as_ref() + } + + /// Set token_type + pub fn set_token_type(mut self, token_type: String) -> Self { + self.token_type = Some(token_type); + self + } + + /// Get token_type + pub fn token_type(&self) -> Option<&String> { + self.token_type.as_ref() + } + + /// Set scope + pub fn set_scope(mut self, scope: String) -> Self { + self.scope = Some(scope); + self + } + + /// Get scope + pub fn scope(&self) -> Option<&String> { + self.scope.as_ref() + } + + /// Set client_id + pub fn set_client_id(mut self, client_id: String) -> Self { + self.client_id = Some(client_id); + self + } + + /// Get client_id + pub fn client_id(&self) -> Option<&String> { + self.client_id.as_ref() + } + + /// Set sub + pub fn set_sub(mut self, sub: String) -> Self { + self.sub = Some(sub); + self + } + + /// Get sub + pub fn sub(&self) -> Option<&String> { + self.sub.as_ref() + } + + /// Set aud + pub fn set_aud(mut self, aud: Vec) -> Self { + self.aud = Some(aud); + self + } + + /// Get aud + pub fn aud(&self) -> Option<&Vec> { + self.aud.as_ref() + } + + /// Set iss + pub fn set_iss(mut self, iss: String) -> Self { + self.iss = Some(iss); + self + } + + /// Get iss + pub fn iss(&self) -> Option<&String> { + self.iss.as_ref() + } + + /// Set exp + pub fn set_exp(mut self, exp: i64) -> Self { + self.exp = Some(exp); + self + } + + /// Get exp + pub fn exp(&self) -> Option<&i64> { + self.exp.as_ref() + } + + /// Set iat + pub fn set_iat(mut self, iat: i64) -> Self { + self.iat = Some(iat); + self + } + + /// Get iat + pub fn iat(&self) -> Option<&i64> { + self.iat.as_ref() + } + + /// Set jti + pub fn set_jti(mut self, jti: String) -> Self { + self.jti = Some(jti); + self + } + + /// Get jti + pub fn jti(&self) -> Option<&String> { + self.jti.as_ref() + } + + /// Set authorization_details + pub fn set_authorization_details( + mut self, + authorization_details: Vec, + ) -> Self { + self.authorization_details = Some(authorization_details); + self + } + + /// Get authorization_details + pub fn authorization_details(&self) -> Option<&Vec> { + self.authorization_details.as_ref() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_oauth2_introspection_creation() { + let _model = ::default(); + let _ = _model.active(); + } + + #[test] + fn test_oauth2_introspection_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/platform_android.rs b/src/models/platform_android.rs index e4144a1..7f35a47 100644 --- a/src/models/platform_android.rs +++ b/src/models/platform_android.rs @@ -24,6 +24,11 @@ pub struct PlatformAndroid { /// Android application ID. #[serde(rename = "applicationId")] 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>, } impl PlatformAndroid { @@ -56,6 +61,17 @@ impl PlatformAndroid { pub fn application_id(&self) -> &String { &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() + } } #[cfg(test)] diff --git a/src/models/policy_password_pwned.rs b/src/models/policy_password_pwned.rs new file mode 100644 index 0000000..8d87473 --- /dev/null +++ b/src/models/policy_password_pwned.rs @@ -0,0 +1,90 @@ +//! PolicyPasswordPwned model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Policy Password Pwned +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct PolicyPasswordPwned { + /// Policy ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// Whether passwords are checked against known data breaches and the result + /// recorded on the user. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// Whether a sign-in with a breached password is refused until the password is + /// reset. + #[serde(rename = "sessions")] + #[serde(default = "default_sessions")] + pub sessions: bool, + /// Whether a breached password is rejected when a user signs up or sets a new + /// password. + #[serde(rename = "users")] + #[serde(default = "default_users")] + pub users: bool, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + true +} + +fn default_sessions() -> bool { + false +} + +fn default_users() -> bool { + false +} + +impl PolicyPasswordPwned { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get sessions + pub fn sessions(&self) -> &bool { + &self.sessions + } + + /// Get users + pub fn users(&self) -> &bool { + &self.users + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_policy_password_pwned_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.enabled(); + let _ = _model.sessions(); + let _ = _model.users(); + } + + #[test] + fn test_policy_password_pwned_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/policy_password_rotation.rs b/src/models/policy_password_rotation.rs new file mode 100644 index 0000000..454f502 --- /dev/null +++ b/src/models/policy_password_rotation.rs @@ -0,0 +1,73 @@ +//! PolicyPasswordRotation model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Policy Password Rotation +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct PolicyPasswordRotation { + /// Policy ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// Whether expired passwords require a reset before email/password sign-in. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// Maximum password age in seconds. + #[serde(rename = "maxAge")] + #[serde(default = "default_max_age")] + pub max_age: i64, +} + +fn default_id() -> String { + "".to_string() +} + +fn default_enabled() -> bool { + false +} + +fn default_max_age() -> i64 { + 31536000 +} + +impl PolicyPasswordRotation { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get max_age + pub fn max_age(&self) -> &i64 { + &self.max_age + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_policy_password_rotation_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.enabled(); + let _ = _model.max_age(); + } + + #[test] + fn test_policy_password_rotation_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/project.rs b/src/models/project.rs index 40a9565..78a7fc7 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -94,10 +94,25 @@ pub struct Project { #[serde(rename = "wafEnabled")] #[serde(skip_serializing_if = "Option::is_none")] pub waf_enabled: Option, + /// ID of the project this environment belongs to. Null when the project is not + /// an environment. + #[serde(rename = "parentId")] + #[serde(skip_serializing_if = "Option::is_none")] + pub parent_id: Option, /// Billing limits reached #[serde(rename = "billingLimits")] #[serde(skip_serializing_if = "Option::is_none")] pub billing_limits: Option, + /// First time the project received a non-console API request. Empty until the + /// project is used. + #[serde(rename = "firstAccessedAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub first_accessed_at: Option, + /// Last time the project was accessed through the MCP server. Empty if it was + /// never accessed via MCP. + #[serde(rename = "mcpAccessedAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub mcp_accessed_at: Option, /// OAuth2 server status #[serde(rename = "oAuth2ServerEnabled")] #[serde(skip_serializing_if = "Option::is_none")] @@ -324,6 +339,17 @@ impl Project { self.waf_enabled.as_ref() } + /// Set parent_id + pub fn set_parent_id(mut self, parent_id: String) -> Self { + self.parent_id = Some(parent_id); + self + } + + /// Get parent_id + pub fn parent_id(&self) -> Option<&String> { + self.parent_id.as_ref() + } + /// Set billing_limits pub fn set_billing_limits(mut self, billing_limits: crate::models::BillingLimits) -> Self { self.billing_limits = Some(billing_limits); @@ -335,6 +361,28 @@ impl Project { self.billing_limits.as_ref() } + /// Set first_accessed_at + pub fn set_first_accessed_at(mut self, first_accessed_at: String) -> Self { + self.first_accessed_at = Some(first_accessed_at); + self + } + + /// Get first_accessed_at + pub fn first_accessed_at(&self) -> Option<&String> { + self.first_accessed_at.as_ref() + } + + /// Set mcp_accessed_at + pub fn set_mcp_accessed_at(mut self, mcp_accessed_at: String) -> Self { + self.mcp_accessed_at = Some(mcp_accessed_at); + self + } + + /// Get mcp_accessed_at + pub fn mcp_accessed_at(&self) -> Option<&String> { + self.mcp_accessed_at.as_ref() + } + /// Set o_auth2_server_enabled pub fn set_o_auth2_server_enabled(mut self, o_auth2_server_enabled: bool) -> Self { self.o_auth2_server_enabled = Some(o_auth2_server_enabled); diff --git a/src/models/topic.rs b/src/models/topic.rs index 8ca0133..976d41b 100644 --- a/src/models/topic.rs +++ b/src/models/topic.rs @@ -30,6 +30,15 @@ pub struct Topic { /// Subscribe permissions. #[serde(rename = "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. + #[serde(rename = "expiry")] + #[serde(skip_serializing_if = "Option::is_none")] + pub expiry: Option, } impl Topic { @@ -72,6 +81,28 @@ impl Topic { pub fn subscribe(&self) -> &Vec { &self.subscribe } + + /// Set qos + pub fn set_qos(mut self, qos: i64) -> Self { + self.qos = Some(qos); + self + } + + /// Get qos + pub fn qos(&self) -> Option<&i64> { + self.qos.as_ref() + } + + /// Set expiry + pub fn set_expiry(mut self, expiry: i64) -> Self { + self.expiry = Some(expiry); + self + } + + /// Get expiry + pub fn expiry(&self) -> Option<&i64> { + self.expiry.as_ref() + } } #[cfg(test)] diff --git a/src/models/user.rs b/src/models/user.rs index 164c8fb..d6e6d2e 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -71,6 +71,11 @@ pub struct User { #[serde(rename = "emailIsCanonical")] #[serde(skip_serializing_if = "Option::is_none")] pub email_is_canonical: Option, + /// Whether the password was found in a known data breach the last time it was + /// checked. Null when the password has never been checked. + #[serde(rename = "passwordPwned")] + #[serde(skip_serializing_if = "Option::is_none")] + pub password_pwned: Option, /// Phone verification status. #[serde(rename = "phoneVerification")] pub phone_verification: bool, @@ -245,6 +250,17 @@ impl User { self.email_is_canonical.as_ref() } + /// Set password_pwned + pub fn set_password_pwned(mut self, password_pwned: bool) -> Self { + self.password_pwned = Some(password_pwned); + self + } + + /// Get password_pwned + pub fn password_pwned(&self) -> Option<&bool> { + self.password_pwned.as_ref() + } + /// Get phone_verification pub fn phone_verification(&self) -> &bool { &self.phone_verification diff --git a/src/models/waf_rule_bypass.rs b/src/models/waf_rule_bypass.rs new file mode 100644 index 0000000..7357694 --- /dev/null +++ b/src/models/waf_rule_bypass.rs @@ -0,0 +1,222 @@ +//! WafRuleBypass model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// WafRuleBypass +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct WafRuleBypass { + /// Rule ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// WAF rule creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// WAF rule last update time in ISO 8601 format. + #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] + pub updated_at: String, + /// Human friendly rule name. + #[serde(rename = "name")] + #[serde(default = "default_name")] + pub name: String, + /// Optional description for the rule. + #[serde(rename = "description")] + #[serde(default = "default_description")] + pub description: String, + /// Team ID. + #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] + pub team_id: String, + /// Project ID. + #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] + pub project_id: String, + /// Resource type the rule is scoped to. + #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] + pub resource_type: String, + /// Resource identifier. Empty for API-wide rules. + #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] + pub resource_id: String, + /// Action performed when the rule matches. + #[serde(rename = "action")] + pub action: crate::enums::WafRuleAction, + /// Evaluation priority. Lower values execute earlier. + #[serde(rename = "priority")] + #[serde(default = "default_priority")] + pub priority: i64, + /// Whether the rule is active. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// List of conditions evaluated for this rule. + #[serde(rename = "conditions")] + #[serde(default = "default_conditions")] + pub conditions: Vec, + /// Action specific configuration. + #[serde(rename = "config")] + #[serde(default = "default_config")] + pub config: 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_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "api".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_priority() -> i64 { + 0 +} + +fn default_enabled() -> bool { + true +} + +fn default_conditions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_config() -> serde_json::Value { + serde_json::json!({}) +} + +impl WafRuleBypass { + /// 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 description + pub fn description(&self) -> &String { + &self.description + } + + /// Get team_id + pub fn team_id(&self) -> &String { + &self.team_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get resource_type + pub fn resource_type(&self) -> &String { + &self.resource_type + } + + /// Get resource_id + pub fn resource_id(&self) -> &String { + &self.resource_id + } + + /// Get action + pub fn action(&self) -> &crate::enums::WafRuleAction { + &self.action + } + + /// Get priority + pub fn priority(&self) -> &i64 { + &self.priority + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get conditions + pub fn conditions(&self) -> &Vec { + &self.conditions + } + + /// Get config + pub fn config(&self) -> &serde_json::Value { + &self.config + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_rule_bypass_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.name(); + let _ = _model.description(); + let _ = _model.team_id(); + let _ = _model.project_id(); + let _ = _model.resource_type(); + let _ = _model.resource_id(); + let _ = _model.action(); + let _ = _model.priority(); + let _ = _model.enabled(); + let _ = _model.conditions(); + let _ = _model.config(); + } + + #[test] + fn test_waf_rule_bypass_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/waf_rule_challenge.rs b/src/models/waf_rule_challenge.rs new file mode 100644 index 0000000..55d6826 --- /dev/null +++ b/src/models/waf_rule_challenge.rs @@ -0,0 +1,266 @@ +//! WafRuleChallenge model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// WafRuleChallenge +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct WafRuleChallenge { + /// Rule ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// WAF rule creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// WAF rule last update time in ISO 8601 format. + #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] + pub updated_at: String, + /// Human friendly rule name. + #[serde(rename = "name")] + #[serde(default = "default_name")] + pub name: String, + /// Optional description for the rule. + #[serde(rename = "description")] + #[serde(default = "default_description")] + pub description: String, + /// Team ID. + #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] + pub team_id: String, + /// Project ID. + #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] + pub project_id: String, + /// Resource type the rule is scoped to. + #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] + pub resource_type: String, + /// Resource identifier. Empty for API-wide rules. + #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] + pub resource_id: String, + /// Action performed when the rule matches. + #[serde(rename = "action")] + pub action: crate::enums::WafRuleAction, + /// Evaluation priority. Lower values execute earlier. + #[serde(rename = "priority")] + #[serde(default = "default_priority")] + pub priority: i64, + /// Whether the rule is active. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// List of conditions evaluated for this rule. + #[serde(rename = "conditions")] + #[serde(default = "default_conditions")] + pub conditions: Vec, + /// Action specific configuration. + #[serde(rename = "config")] + #[serde(default = "default_config")] + pub config: serde_json::Value, + /// Challenge type enforced when the rule matches. + #[serde(rename = "challengeType")] + #[serde(default = "default_challenge_type")] + pub challenge_type: String, + /// Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule + /// matches. + #[serde(rename = "difficulty")] + #[serde(default = "default_difficulty")] + pub difficulty: i64, + /// Seconds a visitor stays cleared after passing the challenge before being + /// challenged again. + #[serde(rename = "ttl")] + #[serde(default = "default_ttl")] + pub ttl: 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_description() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "api".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_priority() -> i64 { + 0 +} + +fn default_enabled() -> bool { + true +} + +fn default_conditions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_config() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_challenge_type() -> String { + "compute".to_string() +} + +fn default_difficulty() -> i64 { + 3 +} + +fn default_ttl() -> i64 { + 1800 +} + +impl WafRuleChallenge { + /// 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 description + pub fn description(&self) -> &String { + &self.description + } + + /// Get team_id + pub fn team_id(&self) -> &String { + &self.team_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get resource_type + pub fn resource_type(&self) -> &String { + &self.resource_type + } + + /// Get resource_id + pub fn resource_id(&self) -> &String { + &self.resource_id + } + + /// Get action + pub fn action(&self) -> &crate::enums::WafRuleAction { + &self.action + } + + /// Get priority + pub fn priority(&self) -> &i64 { + &self.priority + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get conditions + pub fn conditions(&self) -> &Vec { + &self.conditions + } + + /// Get config + pub fn config(&self) -> &serde_json::Value { + &self.config + } + + /// Get challenge_type + pub fn challenge_type(&self) -> &String { + &self.challenge_type + } + + /// Get difficulty + pub fn difficulty(&self) -> &i64 { + &self.difficulty + } + + /// Get ttl + pub fn ttl(&self) -> &i64 { + &self.ttl + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_rule_challenge_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.name(); + let _ = _model.description(); + let _ = _model.team_id(); + let _ = _model.project_id(); + let _ = _model.resource_type(); + let _ = _model.resource_id(); + let _ = _model.action(); + let _ = _model.priority(); + let _ = _model.enabled(); + let _ = _model.conditions(); + let _ = _model.config(); + let _ = _model.challenge_type(); + let _ = _model.difficulty(); + let _ = _model.ttl(); + } + + #[test] + fn test_waf_rule_challenge_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/waf_rule_deny.rs b/src/models/waf_rule_deny.rs new file mode 100644 index 0000000..615bb5d --- /dev/null +++ b/src/models/waf_rule_deny.rs @@ -0,0 +1,222 @@ +//! WafRuleDeny model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// WafRuleDeny +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct WafRuleDeny { + /// Rule ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// WAF rule creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// WAF rule last update time in ISO 8601 format. + #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] + pub updated_at: String, + /// Human friendly rule name. + #[serde(rename = "name")] + #[serde(default = "default_name")] + pub name: String, + /// Optional description for the rule. + #[serde(rename = "description")] + #[serde(default = "default_description")] + pub description: String, + /// Team ID. + #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] + pub team_id: String, + /// Project ID. + #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] + pub project_id: String, + /// Resource type the rule is scoped to. + #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] + pub resource_type: String, + /// Resource identifier. Empty for API-wide rules. + #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] + pub resource_id: String, + /// Action performed when the rule matches. + #[serde(rename = "action")] + pub action: crate::enums::WafRuleAction, + /// Evaluation priority. Lower values execute earlier. + #[serde(rename = "priority")] + #[serde(default = "default_priority")] + pub priority: i64, + /// Whether the rule is active. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// List of conditions evaluated for this rule. + #[serde(rename = "conditions")] + #[serde(default = "default_conditions")] + pub conditions: Vec, + /// Action specific configuration. + #[serde(rename = "config")] + #[serde(default = "default_config")] + pub config: 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_name() -> String { + "".to_string() +} + +fn default_description() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "api".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_priority() -> i64 { + 0 +} + +fn default_enabled() -> bool { + true +} + +fn default_conditions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_config() -> serde_json::Value { + serde_json::json!({}) +} + +impl WafRuleDeny { + /// 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 description + pub fn description(&self) -> &String { + &self.description + } + + /// Get team_id + pub fn team_id(&self) -> &String { + &self.team_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get resource_type + pub fn resource_type(&self) -> &String { + &self.resource_type + } + + /// Get resource_id + pub fn resource_id(&self) -> &String { + &self.resource_id + } + + /// Get action + pub fn action(&self) -> &crate::enums::WafRuleAction { + &self.action + } + + /// Get priority + pub fn priority(&self) -> &i64 { + &self.priority + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get conditions + pub fn conditions(&self) -> &Vec { + &self.conditions + } + + /// Get config + pub fn config(&self) -> &serde_json::Value { + &self.config + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_rule_deny_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.name(); + let _ = _model.description(); + let _ = _model.team_id(); + let _ = _model.project_id(); + let _ = _model.resource_type(); + let _ = _model.resource_id(); + let _ = _model.action(); + let _ = _model.priority(); + let _ = _model.enabled(); + let _ = _model.conditions(); + let _ = _model.config(); + } + + #[test] + fn test_waf_rule_deny_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/waf_rule_list.rs b/src/models/waf_rule_list.rs new file mode 100644 index 0000000..3e515da --- /dev/null +++ b/src/models/waf_rule_list.rs @@ -0,0 +1,59 @@ +//! WafRuleList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// WAF rule list +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct WafRuleList { + /// 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 WafRuleList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get rules + pub fn rules(&self) -> &Vec { + &self.rules + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_rule_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.rules(); + } + + #[test] + fn test_waf_rule_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/waf_rule_rate_limit.rs b/src/models/waf_rule_rate_limit.rs new file mode 100644 index 0000000..2cad554 --- /dev/null +++ b/src/models/waf_rule_rate_limit.rs @@ -0,0 +1,294 @@ +//! WafRuleRateLimit model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// WafRuleRateLimit +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct WafRuleRateLimit { + /// Rule ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// WAF rule creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// WAF rule last update time in ISO 8601 format. + #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] + pub updated_at: String, + /// Human friendly rule name. + #[serde(rename = "name")] + #[serde(default = "default_name")] + pub name: String, + /// Optional description for the rule. + #[serde(rename = "description")] + #[serde(default = "default_description")] + pub description: String, + /// Team ID. + #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] + pub team_id: String, + /// Project ID. + #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] + pub project_id: String, + /// Resource type the rule is scoped to. + #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] + pub resource_type: String, + /// Resource identifier. Empty for API-wide rules. + #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] + pub resource_id: String, + /// Action performed when the rule matches. + #[serde(rename = "action")] + pub action: crate::enums::WafRuleAction, + /// Evaluation priority. Lower values execute earlier. + #[serde(rename = "priority")] + #[serde(default = "default_priority")] + pub priority: i64, + /// Whether the rule is active. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// List of conditions evaluated for this rule. + #[serde(rename = "conditions")] + #[serde(default = "default_conditions")] + pub conditions: Vec, + /// Action specific configuration. + #[serde(rename = "config")] + #[serde(default = "default_config")] + pub config: serde_json::Value, + /// Maximum number of matching requests allowed for the given interval. + #[serde(rename = "limit")] + #[serde(default = "default_limit")] + pub limit: i64, + /// Interval in seconds for the rate limit window. + #[serde(rename = "interval")] + #[serde(default = "default_interval")] + pub interval: i64, + /// Rate limit key: `ip` limits per client IP, `userId` limits per + /// authenticated user. + #[serde(rename = "key")] + #[serde(default = "default_key")] + pub key: String, + /// Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + #[serde(rename = "strategy")] + #[serde(default = "default_strategy")] + pub strategy: String, + /// Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. + /// The sustained refill rate is `limit / interval`. Defaults to `limit`. + #[serde(rename = "maxBucketSize")] + #[serde(default = "default_max_bucket_size")] + pub max_bucket_size: 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_description() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "api".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_priority() -> i64 { + 0 +} + +fn default_enabled() -> bool { + true +} + +fn default_conditions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_config() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_limit() -> i64 { + 100 +} + +fn default_interval() -> i64 { + 3600 +} + +fn default_key() -> String { + "ip".to_string() +} + +fn default_strategy() -> String { + "fixedWindow".to_string() +} + +fn default_max_bucket_size() -> i64 { + 0 +} + +impl WafRuleRateLimit { + /// 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 description + pub fn description(&self) -> &String { + &self.description + } + + /// Get team_id + pub fn team_id(&self) -> &String { + &self.team_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get resource_type + pub fn resource_type(&self) -> &String { + &self.resource_type + } + + /// Get resource_id + pub fn resource_id(&self) -> &String { + &self.resource_id + } + + /// Get action + pub fn action(&self) -> &crate::enums::WafRuleAction { + &self.action + } + + /// Get priority + pub fn priority(&self) -> &i64 { + &self.priority + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get conditions + pub fn conditions(&self) -> &Vec { + &self.conditions + } + + /// Get config + pub fn config(&self) -> &serde_json::Value { + &self.config + } + + /// Get limit + pub fn limit(&self) -> &i64 { + &self.limit + } + + /// Get interval + pub fn interval(&self) -> &i64 { + &self.interval + } + + /// Get key + pub fn key(&self) -> &String { + &self.key + } + + /// Get strategy + pub fn strategy(&self) -> &String { + &self.strategy + } + + /// Get max_bucket_size + pub fn max_bucket_size(&self) -> &i64 { + &self.max_bucket_size + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_rule_rate_limit_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.name(); + let _ = _model.description(); + let _ = _model.team_id(); + let _ = _model.project_id(); + let _ = _model.resource_type(); + let _ = _model.resource_id(); + let _ = _model.action(); + let _ = _model.priority(); + let _ = _model.enabled(); + let _ = _model.conditions(); + let _ = _model.config(); + let _ = _model.limit(); + let _ = _model.interval(); + let _ = _model.key(); + let _ = _model.strategy(); + let _ = _model.max_bucket_size(); + } + + #[test] + fn test_waf_rule_rate_limit_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/waf_rule_redirect.rs b/src/models/waf_rule_redirect.rs new file mode 100644 index 0000000..90182ea --- /dev/null +++ b/src/models/waf_rule_redirect.rs @@ -0,0 +1,250 @@ +//! WafRuleRedirect model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// WafRuleRedirect +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct WafRuleRedirect { + /// Rule ID. + #[serde(rename = "$id")] + #[serde(default = "default_id")] + pub id: String, + /// WAF rule creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + #[serde(default = "default_created_at")] + pub created_at: String, + /// WAF rule last update time in ISO 8601 format. + #[serde(rename = "$updatedAt")] + #[serde(default = "default_updated_at")] + pub updated_at: String, + /// Human friendly rule name. + #[serde(rename = "name")] + #[serde(default = "default_name")] + pub name: String, + /// Optional description for the rule. + #[serde(rename = "description")] + #[serde(default = "default_description")] + pub description: String, + /// Team ID. + #[serde(rename = "teamId")] + #[serde(default = "default_team_id")] + pub team_id: String, + /// Project ID. + #[serde(rename = "projectId")] + #[serde(default = "default_project_id")] + pub project_id: String, + /// Resource type the rule is scoped to. + #[serde(rename = "resourceType")] + #[serde(default = "default_resource_type")] + pub resource_type: String, + /// Resource identifier. Empty for API-wide rules. + #[serde(rename = "resourceId")] + #[serde(default = "default_resource_id")] + pub resource_id: String, + /// Action performed when the rule matches. + #[serde(rename = "action")] + pub action: crate::enums::WafRuleAction, + /// Evaluation priority. Lower values execute earlier. + #[serde(rename = "priority")] + #[serde(default = "default_priority")] + pub priority: i64, + /// Whether the rule is active. + #[serde(rename = "enabled")] + #[serde(default = "default_enabled")] + pub enabled: bool, + /// List of conditions evaluated for this rule. + #[serde(rename = "conditions")] + #[serde(default = "default_conditions")] + pub conditions: Vec, + /// Action specific configuration. + #[serde(rename = "config")] + #[serde(default = "default_config")] + pub config: serde_json::Value, + /// Target location for the redirect. + #[serde(rename = "location")] + #[serde(default = "default_location")] + pub location: String, + /// HTTP status code used for the redirect. + #[serde(rename = "statusCode")] + #[serde(default = "default_status_code")] + pub status_code: 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_description() -> String { + "".to_string() +} + +fn default_team_id() -> String { + "".to_string() +} + +fn default_project_id() -> String { + "".to_string() +} + +fn default_resource_type() -> String { + "api".to_string() +} + +fn default_resource_id() -> String { + "".to_string() +} + +fn default_priority() -> i64 { + 0 +} + +fn default_enabled() -> bool { + true +} + +fn default_conditions() -> Vec { + serde_json::from_value(serde_json::json!([])).unwrap() +} + +fn default_config() -> serde_json::Value { + serde_json::json!({}) +} + +fn default_location() -> String { + "/".to_string() +} + +fn default_status_code() -> i64 { + 302 +} + +impl WafRuleRedirect { + /// 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 description + pub fn description(&self) -> &String { + &self.description + } + + /// Get team_id + pub fn team_id(&self) -> &String { + &self.team_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get resource_type + pub fn resource_type(&self) -> &String { + &self.resource_type + } + + /// Get resource_id + pub fn resource_id(&self) -> &String { + &self.resource_id + } + + /// Get action + pub fn action(&self) -> &crate::enums::WafRuleAction { + &self.action + } + + /// Get priority + pub fn priority(&self) -> &i64 { + &self.priority + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get conditions + pub fn conditions(&self) -> &Vec { + &self.conditions + } + + /// Get config + pub fn config(&self) -> &serde_json::Value { + &self.config + } + + /// Get location + pub fn location(&self) -> &String { + &self.location + } + + /// Get status_code + pub fn status_code(&self) -> &i64 { + &self.status_code + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_rule_redirect_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.name(); + let _ = _model.description(); + let _ = _model.team_id(); + let _ = _model.project_id(); + let _ = _model.resource_type(); + let _ = _model.resource_id(); + let _ = _model.action(); + let _ = _model.priority(); + let _ = _model.enabled(); + let _ = _model.conditions(); + let _ = _model.config(); + let _ = _model.location(); + let _ = _model.status_code(); + } + + #[test] + fn test_waf_rule_redirect_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/services/account.rs b/src/services/account.rs index effe950..9313048 100644 --- a/src/services/account.rs +++ b/src/services/account.rs @@ -837,10 +837,77 @@ impl Account { .await } + /// 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. + pub async fn create_recovery_otp( + &self, + email: impl Into, + phrase: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("email".to_string(), json!(email.into())); + if let Some(value) = phrase { + params.insert("phrase".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 = "/account/recovery/otp".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_recovery_otp( + &self, + user_id: impl Into, + secret: impl Into, + password: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("userId".to_string(), json!(user_id.into())); + params.insert("secret".to_string(), json!(secret.into())); + params.insert("password".to_string(), json!(password.into())); + let mut api_headers = 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/recovery/otp".to_string(); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + /// Get the list of active sessions across different devices for the currently /// logged in user. - pub async fn list_sessions(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_sessions( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -852,9 +919,13 @@ impl Account { } /// Delete all sessions from the user account and remove any sessions cookies - /// from the end client. - pub async fn delete_sessions(&self) -> crate::error::Result<()> { - let params = HashMap::new(); + /// from the end client. Pass `current` as false to keep the session making the + /// request and sign out of every other session. + pub async fn delete_sessions(&self, current: Option) -> crate::error::Result<()> { + let mut params = HashMap::new(); + if let Some(value) = current { + params.insert("current".to_string(), json!(value)); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); @@ -895,10 +966,14 @@ impl Account { &self, email: impl Into, password: impl Into, + duration: Option, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("email".to_string(), json!(email.into())); params.insert("password".to_string(), json!(password.into())); + if let Some(value) = duration { + params.insert("duration".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()); @@ -910,6 +985,82 @@ impl Account { .await } + /// 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). + pub async fn create_id_token_session( + &self, + provider: crate::enums::IdTokenProvider, + id_token: impl Into, + nonce: Option<&str>, + access_token: Option<&str>, + access_token_expiry: Option, + name: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("provider".to_string(), json!(provider)); + params.insert("idToken".to_string(), json!(id_token.into())); + if let Some(value) = nonce { + params.insert("nonce".to_string(), json!(value)); + } + if let Some(value) = access_token { + params.insert("accessToken".to_string(), json!(value)); + } + if let Some(value) = access_token_expiry { + params.insert("accessTokenExpiry".to_string(), json!(value)); + } + if let Some(value) = name { + params.insert("name".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 = "/account/sessions/id-token".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// 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. @@ -1364,6 +1515,63 @@ impl Account { .await } + /// 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. + pub async fn create_email_verification_otp( + &self, + phrase: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = phrase { + params.insert("phrase".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 = "/account/verifications/email/otp".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_email_verification_otp( + &self, + user_id: impl Into, + secret: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("userId".to_string(), json!(user_id.into())); + params.insert("secret".to_string(), json!(secret.into())); + let mut api_headers = 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/verifications/email/otp".to_string(); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + /// Use this endpoint to send a verification SMS to the currently logged in /// user. This endpoint is meant for use after updating a user's phone number /// using the diff --git a/src/services/avatars.rs b/src/services/avatars.rs index f0f7653..fa8cf36 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -1,7 +1,7 @@ //! Avatars service for Appwrite SDK use crate::client::Client; - +use crate::input_file::InputFile; use reqwest::Method; use serde_json::json; use std::collections::HashMap; @@ -297,6 +297,56 @@ impl Avatars { .await } + /// 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. + pub async fn update_photo( + &self, + file: InputFile, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert( + "content-type".to_string(), + "multipart/form-data".to_string(), + ); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/avatars/photo".to_string(); + + self.client + .upload( + Method::PUT, + &path, + Some(api_headers), + params, + "file", + file, + None, + ) + .await + } + + /// 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. + pub async fn delete_photo(&self) -> 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 = "/avatars/photo".to_string(); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + /// 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. pub async fn get_qr( diff --git a/src/services/databases.rs b/src/services/databases.rs index 5d035fc..6d30c67 100644 --- a/src/services/databases.rs +++ b/src/services/databases.rs @@ -83,6 +83,7 @@ impl Databases { pub async fn list_transactions( &self, queries: Option>, + total: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = queries { @@ -91,6 +92,9 @@ impl Databases { 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()); diff --git a/src/services/documents_db.rs b/src/services/documents_db.rs index 768aef5..6f761f7 100644 --- a/src/services/documents_db.rs +++ b/src/services/documents_db.rs @@ -106,6 +106,7 @@ impl DocumentsDB { pub async fn list_transactions( &self, queries: Option>, + total: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = queries { @@ -114,6 +115,9 @@ impl DocumentsDB { 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()); diff --git a/src/services/domains.rs b/src/services/domains.rs new file mode 100644 index 0000000..2f8b733 --- /dev/null +++ b/src/services/domains.rs @@ -0,0 +1,1893 @@ +//! Domains service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct Domains { + client: Client, +} + +impl Domains { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// List all domains registered for this project. This endpoint supports + /// pagination. + pub async fn list( + &self, + queries: Option>, + search: Option<&str>, + ) -> 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) = search { + params.insert("search".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/domains".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create( + &self, + team_id: impl Into, + domain: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("teamId".to_string(), json!(team_id.into())); + params.insert("domain".to_string(), json!(domain.into())); + let mut api_headers = 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 = "/domains".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get the registration price for a domain name. + pub async fn get_price( + &self, + domain: impl Into, + period_years: Option, + registration_type: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("domain".to_string(), json!(domain.into())); + if let Some(value) = period_years { + params.insert("periodYears".to_string(), json!(value)); + } + if let Some(value) = registration_type { + params.insert("registrationType".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/domains/price".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn list_prices( + &self, + domains: impl IntoIterator>, + period_years: Option, + registration_type: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert( + "domains".to_string(), + json!(domains + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); + if let Some(value) = period_years { + params.insert("periodYears".to_string(), json!(value)); + } + if let Some(value) = registration_type { + params.insert("registrationType".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/domains/prices".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a domain by its unique ID. + pub async fn get( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn delete(&self, domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the registrar nameservers for the given domain. When nameservers are + /// not provided, + /// the domain will be updated to use Appwrite nameservers. + pub async fn update_nameservers( + &self, + domain_id: impl Into, + nameservers: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = nameservers { + params.insert( + "nameservers".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/nameservers" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn verify_nameservers( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/nameservers/verification" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// List Google Workspace DNS records. + pub async fn get_preset_google_workspace( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/google-workspace" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Add Google Workspace DNS records to the domain. This will create the + /// required MX records + /// for Google Workspace email hosting. + pub async fn create_preset_google_workspace( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/google-workspace" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List iCloud DNS records. + pub async fn get_preset_i_cloud( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/icloud" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Add iCloud DNS records to the domain. This will create the required MX and + /// SPF records + /// for using iCloud email services with your domain. + pub async fn create_preset_i_cloud( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/icloud" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List Mailgun DNS records. + pub async fn get_preset_mailgun( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/mailgun" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Add Mailgun DNS records to the domain. This endpoint will create the + /// required DNS records + /// for Mailgun in the specified domain. + pub async fn create_preset_mailgun( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/mailgun" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List Outlook DNS records. + pub async fn get_preset_outlook( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/outlook" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Add Outlook DNS records to the domain. This will create the required MX + /// records + /// for setting up Outlook email hosting for your domain. + pub async fn create_preset_outlook( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/outlook" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List ProtonMail DNS records. + pub async fn get_preset_proton_mail( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/proton-mail" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Add ProtonMail DNS records to the domain. This will create the required MX + /// records + /// for using ProtonMail with your custom domain. + pub async fn create_preset_proton_mail( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/proton-mail" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List Zoho DNS records. + pub async fn get_preset_zoho( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/zoho" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Add Zoho Mail DNS records to the domain. This will create the required MX + /// records + /// for setting up Zoho Mail on your domain. + pub async fn create_preset_zoho( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/presets/zoho" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List DNS records for a given domain. You can use this endpoint to list all + /// the DNS records + /// associated with your domain. + pub async fn list_records( + &self, + domain_id: impl Into, + queries: 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::>()), + ); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_a( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/a" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_a( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/a/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_aaaa( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/aaaa" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_aaaa( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/aaaa/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_alias( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/alias" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_alias( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/alias/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_caa( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/caa" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_caa( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/caa/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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'. + pub async fn create_record_cname( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/cname" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Update an existing CNAME record for the given domain. + pub async fn update_record_cname( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/cname/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_https( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/https" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_https( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/https/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_mx( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + priority: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + params.insert("priority".to_string(), json!(priority)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/mx" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Update an existing MX record for the given domain. + #[allow(clippy::too_many_arguments)] + pub async fn update_record_mx( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + priority: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + params.insert("priority".to_string(), json!(priority)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/mx/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_ns( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/ns" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_ns( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/ns/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + #[allow(clippy::too_many_arguments)] + pub async fn create_record_srv( + &self, + domain_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + priority: i64, + weight: i64, + port: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + params.insert("priority".to_string(), json!(priority)); + params.insert("weight".to_string(), json!(weight)); + params.insert("port".to_string(), json!(port)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/srv" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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 + #[allow(clippy::too_many_arguments)] + pub async fn update_record_srv( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + priority: i64, + weight: i64, + port: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + params.insert("priority".to_string(), json!(priority)); + params.insert("weight".to_string(), json!(weight)); + params.insert("port".to_string(), json!(port)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/srv/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_record_txt( + &self, + domain_id: impl Into, + name: impl Into, + ttl: i64, + value: Option<&str>, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = value { + params.insert("value".to_string(), json!(value)); + } + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/txt" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_record_txt( + &self, + domain_id: impl Into, + record_id: impl Into, + name: impl Into, + value: impl Into, + ttl: i64, + comment: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + params.insert("value".to_string(), json!(value.into())); + params.insert("ttl".to_string(), json!(ttl)); + if let Some(value) = comment { + params.insert("comment".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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/txt/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn get_record( + &self, + domain_id: impl Into, + record_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a DNS record for the given domain. This endpoint allows you to + /// delete an existing DNS record + /// from a specific domain. + pub async fn delete_record( + &self, + domain_id: impl Into, + record_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let record_id = record_id.into(); + if record_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"recordId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/records/{recordId}" + .to_string() + .replace("{domainId}", &domain_id) + .replace("{recordId}", &record_id); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_team( + &self, + domain_id: impl Into, + team_id: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("teamId".to_string(), json!(team_id.into())); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/team" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Retrieve the current transfer status for a domain. Returns the status, an + /// optional reason, and a timestamp of the last status change. + pub async fn get_transfer_status( + &self, + domain_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 domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/transfers/status" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn get_zone(&self, domain_id: impl Into) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "text/plain".to_string()); + + let domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/zone" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call_text(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_zone( + &self, + domain_id: impl Into, + content: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("content".to_string(), json!(content.into())); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let domain_id = domain_id.into(); + if domain_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"domainId\"", + None, + String::new(), + )); + } + + let path = "/domains/{domainId}/zone" + .to_string() + .replace("{domainId}", &domain_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for Domains { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_domains_creation() { + let client = Client::new(); + let service = Domains::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} diff --git a/src/services/functions.rs b/src/services/functions.rs index a05706a..3dd0131 100644 --- a/src/services/functions.rs +++ b/src/services/functions.rs @@ -174,8 +174,14 @@ impl Functions { } /// Get a list of all runtimes that are currently active on your instance. - pub async fn list_runtimes(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_runtimes( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -190,11 +196,15 @@ impl Functions { pub async fn list_specifications( &self, r#type: Option<&str>, + total: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { params.insert("type".to_string(), json!(value)); } + 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()); diff --git a/src/services/locale.rs b/src/services/locale.rs index 3653b8f..21c1825 100644 --- a/src/services/locale.rs +++ b/src/services/locale.rs @@ -3,7 +3,7 @@ use crate::client::Client; use reqwest::Method; - +use serde_json::json; use std::collections::HashMap; /// The Locale service allows you to customize your app based on your users' @@ -44,8 +44,14 @@ impl Locale { /// List of all locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). - pub async fn list_codes(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_codes( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -58,8 +64,14 @@ impl Locale { /// List of all continents. You can use the locale header to get the data in a /// supported language. - pub async fn list_continents(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_continents( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -72,8 +84,14 @@ impl Locale { /// List of all countries. You can use the locale header to get the data in a /// supported language. - pub async fn list_countries(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_countries( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -86,8 +104,14 @@ impl Locale { /// List of all countries that are currently members of the EU. You can use the /// locale header to get the data in a supported language. - pub async fn list_countries_eu(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_countries_eu( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -100,8 +124,14 @@ impl Locale { /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. - pub async fn list_countries_phones(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_countries_phones( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -115,8 +145,14 @@ impl Locale { /// List of all currencies, including currency symbol, name, plural, and /// decimal digits for all major and minor currencies. You can use the locale /// header to get the data in a supported language. - pub async fn list_currencies(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_currencies( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -129,8 +165,14 @@ impl Locale { /// List of all languages classified by ISO 639-1 including 2-letter code, name /// in English, and name in the respective language. - pub async fn list_languages(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_languages( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); diff --git a/src/services/messaging.rs b/src/services/messaging.rs index e83e71a..71dc9c2 100644 --- a/src/services/messaging.rs +++ b/src/services/messaging.rs @@ -70,6 +70,8 @@ impl Messaging { draft: Option, html: Option, scheduled_at: Option<&str>, + reply_to_email: Option<&str>, + reply_to_name: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("messageId".to_string(), json!(message_id.into())); @@ -120,6 +122,12 @@ impl Messaging { if let Some(value) = scheduled_at { params.insert("scheduledAt".to_string(), json!(value)); } + if let Some(value) = reply_to_email { + params.insert("replyToEmail".to_string(), json!(value)); + } + if let Some(value) = reply_to_name { + params.insert("replyToName".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()); @@ -149,6 +157,8 @@ impl Messaging { bcc: Option>, scheduled_at: Option<&str>, attachments: Option>, + reply_to_email: Option<&str>, + reply_to_name: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = topics { @@ -202,6 +212,12 @@ impl Messaging { json!(value.into_iter().map(|s| s.into()).collect::>()), ); } + if let Some(value) = reply_to_email { + params.insert("replyToEmail".to_string(), json!(value)); + } + if let Some(value) = reply_to_name { + params.insert("replyToName".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()); @@ -238,6 +254,7 @@ impl Messaging { content_available: Option, critical: Option, priority: Option, + channel_id: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("messageId".to_string(), json!(message_id.into())); @@ -304,6 +321,9 @@ impl Messaging { if let Some(value) = priority { params.insert("priority".to_string(), json!(value)); } + if let Some(value) = channel_id { + params.insert("channelId".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()); @@ -340,6 +360,7 @@ impl Messaging { content_available: Option, critical: Option, priority: Option, + channel_id: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = topics { @@ -405,6 +426,9 @@ impl Messaging { if let Some(value) = priority { params.insert("priority".to_string(), json!(value)); } + if let Some(value) = channel_id { + params.insert("channelId".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()); @@ -709,6 +733,83 @@ impl Messaging { .await } + /// Create a new Appwrite push provider. + pub async fn create_appwrite_provider( + &self, + provider_id: impl Into, + name: impl Into, + enabled: Option, + qos: Option, + expiry: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("providerId".to_string(), json!(provider_id.into())); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = qos { + params.insert("qos".to_string(), json!(value)); + } + if let Some(value) = expiry { + params.insert("expiry".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 = "/messaging/providers/appwrite".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Update an Appwrite push provider by its unique ID. + pub async fn update_appwrite_provider( + &self, + provider_id: impl Into, + name: Option<&str>, + enabled: Option, + qos: Option, + expiry: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = name { + params.insert("name".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = qos { + params.insert("qos".to_string(), json!(value)); + } + if let Some(value) = expiry { + params.insert("expiry".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 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/appwrite/{providerId}" + .to_string() + .replace("{providerId}", &provider_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Create a new Firebase Cloud Messaging provider. pub async fn create_fcm_provider( &self, @@ -1758,6 +1859,8 @@ impl Messaging { topic_id: impl Into, name: impl Into, subscribe: Option>, + qos: Option, + expiry: Option, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("topicId".to_string(), json!(topic_id.into())); @@ -1768,6 +1871,12 @@ impl Messaging { json!(value.into_iter().map(|s| s.into()).collect::>()), ); } + if let Some(value) = qos { + params.insert("qos".to_string(), json!(value)); + } + if let Some(value) = expiry { + params.insert("expiry".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()); @@ -1803,6 +1912,8 @@ impl Messaging { topic_id: impl Into, name: Option<&str>, subscribe: Option>, + qos: Option, + expiry: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = name { @@ -1814,6 +1925,12 @@ impl Messaging { json!(value.into_iter().map(|s| s.into()).collect::>()), ); } + if let Some(value) = qos { + params.insert("qos".to_string(), json!(value)); + } + if let Some(value) = expiry { + params.insert("expiry".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()); diff --git a/src/services/mod.rs b/src/services/mod.rs index 3776795..822f966 100644 --- a/src/services/mod.rs +++ b/src/services/mod.rs @@ -14,6 +14,8 @@ pub mod databases; pub use databases::Databases; pub mod documents_db; pub use documents_db::DocumentsDB; +pub mod domains; +pub use domains::Domains; pub mod embeddings; pub use embeddings::Embeddings; pub mod functions; @@ -56,6 +58,8 @@ pub mod users; pub use users::Users; pub mod vectors_db; pub use vectors_db::VectorsDB; +pub mod waf; +pub use waf::Waf; pub mod webhooks; pub use webhooks::Webhooks; @@ -77,6 +81,7 @@ pub struct Services { backups: Backups, databases: Databases, documents_db: DocumentsDB, + domains: Domains, embeddings: Embeddings, functions: Functions, graphql: Graphql, @@ -98,6 +103,7 @@ pub struct Services { tokens: Tokens, users: Users, vectors_db: VectorsDB, + waf: Waf, webhooks: Webhooks, } @@ -112,6 +118,7 @@ impl Services { backups: Backups::new(&client), databases: Databases::new(&client), documents_db: DocumentsDB::new(&client), + domains: Domains::new(&client), embeddings: Embeddings::new(&client), functions: Functions::new(&client), graphql: Graphql::new(&client), @@ -133,6 +140,7 @@ impl Services { tokens: Tokens::new(&client), users: Users::new(&client), vectors_db: VectorsDB::new(&client), + waf: Waf::new(&client), webhooks: Webhooks::new(&client), client, } @@ -171,6 +179,10 @@ impl Services { pub fn documents_db(&self) -> &DocumentsDB { &self.documents_db } + /// Get Domains service + pub fn domains(&self) -> &Domains { + &self.domains + } /// Get Embeddings service pub fn embeddings(&self) -> &Embeddings { &self.embeddings @@ -255,6 +267,10 @@ impl Services { pub fn vectors_db(&self) -> &VectorsDB { &self.vectors_db } + /// Get Waf service + pub fn waf(&self) -> &Waf { + &self.waf + } /// Get Webhooks service pub fn webhooks(&self) -> &Webhooks { &self.webhooks diff --git a/src/services/oauth2.rs b/src/services/oauth2.rs index e46bfaf..834934a 100644 --- a/src/services/oauth2.rs +++ b/src/services/oauth2.rs @@ -336,6 +336,47 @@ impl Oauth2 { .await } + /// 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. + pub async fn introspect( + &self, + token: impl Into, + token_type_hint: Option<&str>, + client_id: Option<&str>, + client_secret: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("token".to_string(), json!(token.into())); + if let Some(value) = token_type_hint { + params.insert("token_type_hint".to_string(), json!(value)); + } + if let Some(value) = client_id { + params.insert("client_id".to_string(), json!(value)); + } + if let Some(value) = client_secret { + params.insert("client_secret".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 = "/oauth2/{project_id}/introspect".to_string().replace( + "{project_id}", + &self + .client + .get_headers() + .get("x-appwrite-project") + .cloned() + .unwrap_or_default(), + ); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + /// List the organizations the OAuth2 access token can access. Resolves the /// token's `organization` authorization details, expanding the `*` wildcard /// into the concrete set of organizations the user can see. diff --git a/src/services/organization.rs b/src/services/organization.rs index ccc9a26..176b0f5 100644 --- a/src/services/organization.rs +++ b/src/services/organization.rs @@ -541,6 +541,215 @@ impl Organization { .call(Method::DELETE, &path, Some(api_headers), Some(params)) .await } + + /// Get a list of all API keys of a project in your organization. + pub async fn list_project_keys( + &self, + project_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 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}/keys" + .to_string() + .replace("{projectId}", &project_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_ephemeral_project_key( + &self, + project_id: impl Into, + scopes: Vec, + duration: i64, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("scopes".to_string(), json!(scopes)); + params.insert("duration".to_string(), json!(duration)); + let mut api_headers = 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}/keys/ephemeral" + .to_string() + .replace("{projectId}", &project_id); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a project key by its unique ID. + pub async fn get_project_key( + &self, + project_id: impl Into, + 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 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 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 = "/organization/projects/{projectId}/keys/{keyId}" + .to_string() + .replace("{projectId}", &project_id) + .replace("{keyId}", &key_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a project key by its unique ID. Use this endpoint to update the + /// name, scopes, or expiration time of an API key. + pub async fn update_project_key( + &self, + project_id: impl Into, + 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 mut api_headers = 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 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 = "/organization/projects/{projectId}/keys/{keyId}" + .to_string() + .replace("{projectId}", &project_id) + .replace("{keyId}", &key_id); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a project key by its unique ID. Once deleted, the key can no longer + /// be used to authenticate API calls. + pub async fn delete_project_key( + &self, + project_id: impl Into, + 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()); + 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 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 = "/organization/projects/{projectId}/keys/{keyId}" + .to_string() + .replace("{projectId}", &project_id) + .replace("{keyId}", &key_id); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } } impl crate::services::Service for Organization { diff --git a/src/services/project.rs b/src/services/project.rs index fc2c163..43c2af2 100644 --- a/src/services/project.rs +++ b/src/services/project.rs @@ -70,6 +70,143 @@ impl Project { .await } + /// Get a list of all environments of the project. You can use the query params + /// to filter your results. + pub async fn list_environments( + &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 = "/project/environments".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn create_environment( + &self, + environment_id: impl Into, + name: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("environmentId".to_string(), json!(environment_id.into())); + params.insert("name".to_string(), json!(name.into())); + let mut api_headers = 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/environments".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get an environment of the project by its unique ID. + pub async fn get_environment( + &self, + environment_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 environment_id = environment_id.into(); + if environment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"environmentId\"", + None, + String::new(), + )); + } + + let path = "/project/environments/{environmentId}" + .to_string() + .replace("{environmentId}", &environment_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the name of an environment of the project. + pub async fn update_environment( + &self, + environment_id: impl Into, + name: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let environment_id = environment_id.into(); + if environment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"environmentId\"", + None, + String::new(), + )); + } + + let path = "/project/environments/{environmentId}" + .to_string() + .replace("{environmentId}", &environment_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete an environment of the project, with all of its resources and users. + pub async fn delete_environment( + &self, + environment_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 environment_id = environment_id.into(); + if environment_id.is_empty() { + return Err(crate::error::AppwriteError::new( + 0, + "Missing required parameter: \"environmentId\"", + None, + String::new(), + )); + } + + let path = "/project/environments/{environmentId}" + .to_string() + .replace("{environmentId}", &environment_id); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + /// Get a list of all API keys from the current project. pub async fn list_keys( &self, @@ -461,6 +598,7 @@ impl Project { } /// Update the project OAuth2 Apple configuration. + #[allow(clippy::too_many_arguments)] pub async fn update_o_auth2_apple( &self, service_id: Option<&str>, @@ -468,6 +606,8 @@ impl Project { team_id: Option<&str>, p8_file: Option<&str>, enabled: Option, + native_client_ids: Option>, + native_enabled: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = service_id { @@ -485,6 +625,15 @@ impl Project { if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } + if let Some(value) = native_client_ids { + params.insert( + "nativeClientIds".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = native_enabled { + params.insert("nativeEnabled".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()); @@ -531,6 +680,7 @@ impl Project { client_secret: Option<&str>, endpoint: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -545,6 +695,9 @@ impl Project { 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()); @@ -762,6 +915,7 @@ impl Project { client_id: Option<&str>, client_secret: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -773,6 +927,9 @@ impl Project { 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()); @@ -962,6 +1119,7 @@ impl Project { client_id: Option<&str>, client_secret: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -973,6 +1131,9 @@ impl Project { 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()); @@ -1023,6 +1184,8 @@ impl Project { client_secret: Option<&str>, prompt: Option>, enabled: Option, + native_client_ids: Option>, + native_enabled: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1037,6 +1200,15 @@ impl Project { if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } + if let Some(value) = native_client_ids { + params.insert( + "nativeClientIds".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = native_enabled { + params.insert("nativeEnabled".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()); @@ -1076,6 +1248,38 @@ impl Project { .await } + /// Update the project OAuth2 Kakao configuration. + pub async fn update_o_auth2_kakao( + &self, + client_id: Option<&str>, + client_secret: Option<&str>, + prompt: Option>, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = client_id { + params.insert("clientId".to_string(), json!(value)); + } + 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)); + } + let mut api_headers = 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/oauth2/kakao".to_string(); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Update the project OAuth2 Keycloak configuration. pub async fn update_o_auth2_keycloak( &self, @@ -1175,6 +1379,7 @@ impl Project { application_secret: Option<&str>, tenant: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = application_id { @@ -1189,6 +1394,9 @@ impl Project { 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()); @@ -1289,6 +1497,7 @@ impl Project { domain: Option<&str>, authorization_server_id: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1306,6 +1515,9 @@ impl Project { 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()); @@ -1435,6 +1647,7 @@ impl Project { customer_key: Option<&str>, customer_secret: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = customer_key { @@ -1446,6 +1659,9 @@ impl Project { 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()); @@ -1541,6 +1757,34 @@ impl Project { .await } + /// Update the project OAuth2 TikTok configuration. + pub async fn update_o_auth2_tik_tok( + &self, + client_id: Option<&str>, + client_secret: Option<&str>, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = client_id { + params.insert("clientId".to_string(), json!(value)); + } + if let Some(value) = client_secret { + params.insert("clientSecret".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".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 = "/project/oauth2/tiktok".to_string(); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Update the project OAuth2 Tradeshift configuration. pub async fn update_o_auth2_tradeshift( &self, @@ -1625,6 +1869,34 @@ impl Project { .await } + /// Update the project OAuth2 Webflow configuration. + pub async fn update_o_auth2_webflow( + &self, + client_id: Option<&str>, + client_secret: Option<&str>, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = client_id { + params.insert("clientId".to_string(), json!(value)); + } + if let Some(value) = client_secret { + params.insert("clientSecret".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".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 = "/project/oauth2/webflow".to_string(); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Update the project OAuth2 WordPress configuration. pub async fn update_o_auth2_word_press( &self, @@ -1743,6 +2015,7 @@ impl Project { client_id: Option<&str>, client_secret: Option<&str>, enabled: Option, + prompt: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = client_id { @@ -1754,6 +2027,9 @@ impl Project { 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()); @@ -1847,11 +2123,18 @@ impl Project { platform_id: impl Into, name: impl Into, application_id: impl Into, + fingerprints: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("platformId".to_string(), json!(platform_id.into())); params.insert("name".to_string(), json!(name.into())); params.insert("applicationId".to_string(), json!(application_id.into())); + if let Some(value) = fingerprints { + params.insert( + "fingerprints".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); @@ -1870,10 +2153,17 @@ impl Project { platform_id: impl Into, name: impl Into, application_id: impl Into, + fingerprints: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); params.insert("applicationId".to_string(), json!(application_id.into())); + if let Some(value) = fingerprints { + params.insert( + "fingerprints".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); @@ -2401,6 +2691,67 @@ impl Project { .await } + /// 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. + pub async fn update_password_pwned_policy( + &self, + enabled: Option, + sessions: Option, + users: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = sessions { + params.insert("sessions".to_string(), json!(value)); + } + if let Some(value) = users { + params.insert("users".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 = "/project/policies/password-pwned".to_string(); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// 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. + pub async fn update_password_rotation_policy( + &self, + enabled: Option, + max_age: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = max_age { + params.insert("maxAge".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 = "/project/policies/password-rotation".to_string(); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + /// Update the password strength requirements for users in the project. pub async fn update_password_strength_policy( &self, diff --git a/src/services/sites.rs b/src/services/sites.rs index 86dcaea..150a50d 100644 --- a/src/services/sites.rs +++ b/src/services/sites.rs @@ -167,8 +167,14 @@ impl Sites { /// Get a list of all frameworks that are currently available on the server /// instance. - pub async fn list_frameworks(&self) -> crate::error::Result { - let params = HashMap::new(); + pub async fn list_frameworks( + &self, + total: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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()); @@ -183,11 +189,15 @@ impl Sites { pub async fn list_specifications( &self, r#type: Option<&str>, + total: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = r#type { params.insert("type".to_string(), json!(value)); } + 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()); diff --git a/src/services/tables_db.rs b/src/services/tables_db.rs index 2e98975..a9f0f21 100644 --- a/src/services/tables_db.rs +++ b/src/services/tables_db.rs @@ -112,6 +112,7 @@ impl TablesDB { pub async fn list_transactions( &self, queries: Option>, + total: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = queries { @@ -120,6 +121,9 @@ impl TablesDB { 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()); diff --git a/src/services/teams.rs b/src/services/teams.rs index 62a9fc3..5f55c5b 100644 --- a/src/services/teams.rs +++ b/src/services/teams.rs @@ -333,6 +333,7 @@ impl Teams { phone: Option<&str>, url: Option<&str>, name: Option<&str>, + membership_id: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = email { @@ -354,6 +355,9 @@ impl Teams { if let Some(value) = name { params.insert("name".to_string(), json!(value)); } + if let Some(value) = membership_id { + params.insert("membershipId".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()); diff --git a/src/services/vectors_db.rs b/src/services/vectors_db.rs index f45e613..be3894b 100644 --- a/src/services/vectors_db.rs +++ b/src/services/vectors_db.rs @@ -106,6 +106,7 @@ impl VectorsDB { pub async fn list_transactions( &self, queries: Option>, + total: Option, ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = queries { @@ -114,6 +115,9 @@ impl VectorsDB { 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()); diff --git a/src/services/waf.rs b/src/services/waf.rs new file mode 100644 index 0000000..82c65f2 --- /dev/null +++ b/src/services/waf.rs @@ -0,0 +1,787 @@ +//! Waf service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct Waf { + client: Client, +} + +impl Waf { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// List WAF rules for the current project. + pub async fn list_rules( + &self, + queries: Option>, + search: Option<&str>, + 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) = search { + params.insert("search".to_string(), json!(value)); + } + 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 = "/waf/rules".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn create_bypass_rule( + &self, + rule_id: impl Into, + resource_type: impl Into, + name: impl Into, + resource_id: Option<&str>, + description: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("ruleId".to_string(), json!(rule_id.into())); + params.insert("resourceType".to_string(), json!(resource_type.into())); + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/bypass".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn update_bypass_rule( + &self, + rule_id: impl Into, + resource_type: Option<&str>, + resource_id: Option<&str>, + name: Option<&str>, + description: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = resource_type { + params.insert("resourceType".to_string(), json!(value)); + } + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + if let Some(value) = name { + params.insert("name".to_string(), json!(value)); + } + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/bypass/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, `queryKeys`, + /// `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + /// on `city` and `state` require the premium Geo DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn create_challenge_rule( + &self, + rule_id: impl Into, + resource_type: impl Into, + name: impl Into, + resource_id: Option<&str>, + description: Option<&str>, + challenge_type: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + difficulty: Option, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("ruleId".to_string(), json!(rule_id.into())); + params.insert("resourceType".to_string(), json!(resource_type.into())); + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = challenge_type { + params.insert("challengeType".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = difficulty { + params.insert("difficulty".to_string(), json!(value)); + } + if let Some(value) = ttl { + params.insert("ttl".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 = "/waf/rules/challenge".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, `queryKeys`, + /// `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + /// on `city` and `state` require the premium Geo DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn update_challenge_rule( + &self, + rule_id: impl Into, + resource_type: Option<&str>, + resource_id: Option<&str>, + name: Option<&str>, + description: Option<&str>, + challenge_type: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + difficulty: Option, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = resource_type { + params.insert("resourceType".to_string(), json!(value)); + } + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + if let Some(value) = name { + params.insert("name".to_string(), json!(value)); + } + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = challenge_type { + params.insert("challengeType".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = difficulty { + params.insert("difficulty".to_string(), json!(value)); + } + if let Some(value) = ttl { + params.insert("ttl".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 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 = "/waf/rules/challenge/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn create_deny_rule( + &self, + rule_id: impl Into, + resource_type: impl Into, + name: impl Into, + resource_id: Option<&str>, + description: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("ruleId".to_string(), json!(rule_id.into())); + params.insert("resourceType".to_string(), json!(resource_type.into())); + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/deny".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn update_deny_rule( + &self, + rule_id: impl Into, + resource_type: Option<&str>, + resource_id: Option<&str>, + name: Option<&str>, + description: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = resource_type { + params.insert("resourceType".to_string(), json!(value)); + } + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + if let Some(value) = name { + params.insert("name".to_string(), json!(value)); + } + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/deny/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, `queryKeys`, `userAgent`, `os`, + /// `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + /// `state` require the premium Geo DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn create_rate_limit_rule( + &self, + rule_id: impl Into, + resource_type: impl Into, + name: impl Into, + limit: i64, + interval: i64, + resource_id: Option<&str>, + description: Option<&str>, + key: Option<&str>, + strategy: Option<&str>, + max_bucket_size: Option, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("ruleId".to_string(), json!(rule_id.into())); + params.insert("resourceType".to_string(), json!(resource_type.into())); + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + params.insert("limit".to_string(), json!(limit)); + params.insert("interval".to_string(), json!(interval)); + if let Some(value) = key { + params.insert("key".to_string(), json!(value)); + } + if let Some(value) = strategy { + params.insert("strategy".to_string(), json!(value)); + } + if let Some(value) = max_bucket_size { + params.insert("maxBucketSize".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/rate-limit".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, `queryKeys`, `userAgent`, `os`, + /// `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + /// `state` require the premium Geo DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn update_rate_limit_rule( + &self, + rule_id: impl Into, + resource_type: Option<&str>, + resource_id: Option<&str>, + name: Option<&str>, + description: Option<&str>, + limit: Option, + interval: Option, + key: Option<&str>, + max_bucket_size: Option, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = resource_type { + params.insert("resourceType".to_string(), json!(value)); + } + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + if let Some(value) = name { + params.insert("name".to_string(), json!(value)); + } + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = interval { + params.insert("interval".to_string(), json!(value)); + } + if let Some(value) = key { + params.insert("key".to_string(), json!(value)); + } + if let Some(value) = max_bucket_size { + params.insert("maxBucketSize".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/rate-limit/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn create_redirect_rule( + &self, + rule_id: impl Into, + resource_type: impl Into, + name: impl Into, + location: impl Into, + status_code: i64, + resource_id: Option<&str>, + description: Option<&str>, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("ruleId".to_string(), json!(rule_id.into())); + params.insert("resourceType".to_string(), json!(resource_type.into())); + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + params.insert("location".to_string(), json!(location.into())); + params.insert("statusCode".to_string(), json!(status_code)); + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/redirect".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// 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.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + #[allow(clippy::too_many_arguments)] + pub async fn update_redirect_rule( + &self, + rule_id: impl Into, + resource_type: Option<&str>, + resource_id: Option<&str>, + name: Option<&str>, + description: Option<&str>, + location: Option<&str>, + status_code: Option, + priority: Option, + enabled: Option, + conditions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = resource_type { + params.insert("resourceType".to_string(), json!(value)); + } + if let Some(value) = resource_id { + params.insert("resourceId".to_string(), json!(value)); + } + if let Some(value) = name { + params.insert("name".to_string(), json!(value)); + } + if let Some(value) = description { + params.insert("description".to_string(), json!(value)); + } + if let Some(value) = location { + params.insert("location".to_string(), json!(value)); + } + if let Some(value) = status_code { + params.insert("statusCode".to_string(), json!(value)); + } + if let Some(value) = priority { + params.insert("priority".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = conditions { + params.insert( + "conditions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + let mut api_headers = 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 = "/waf/rules/redirect/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a WAF rule by its ID. + pub async fn get_rule( + &self, + rule_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 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 = "/waf/rules/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a WAF rule. + pub async fn delete_rule(&self, rule_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 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 = "/waf/rules/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for Waf { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_waf_creation() { + let client = Client::new(); + let service = Waf::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} From 47d59753f50ef8636b166a8dc4a9fca25292ca41 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 13:15:01 +0100 Subject: [PATCH 2/2] fix: upload profile photos in a single request avatars.update_photo went through the chunking uploader, so a client with a chunk size below the photo size split it into chunks the endpoint does not accept. It now uses a single-request upload. --- src/client.rs | 16 ++++++++++++++++ src/services/avatars.rs | 31 ++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/client.rs b/src/client.rs index 7db52e8..946094f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -929,6 +929,22 @@ 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, diff --git a/src/services/avatars.rs b/src/services/avatars.rs index fa8cf36..60c40ab 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -317,15 +317,7 @@ impl Avatars { let path = "/avatars/photo".to_string(); self.client - .upload( - Method::PUT, - &path, - Some(api_headers), - params, - "file", - file, - None, - ) + .single_upload(Method::PUT, &path, Some(api_headers), params, "file", file) .await } @@ -491,6 +483,27 @@ 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();