diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad9e1b..0577b25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.13.0] - TBD +## [0.14.0-rc.1] - TBD ### Added - Initial release of Appwrite Rust SDK @@ -25,18 +25,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Account service with 59 methods - Activities service with 2 methods - Apps service with 22 methods -- Avatars service with 8 methods +- Avatars service with 9 methods - Backups service with 12 methods - Databases service with 71 methods +- DocumentsDB service with 37 methods - Embeddings service with 1 methods - Functions service with 26 methods - Graphql service with 2 methods - Locale service with 8 methods - Messaging service with 54 methods +- Mongo service with 31 methods +- Mysql service with 34 methods - Oauth2 service with 12 methods - Organization service with 23 methods +- Postgresql service with 37 methods - Presences service with 5 methods -- Project service with 102 methods +- Project service with 103 methods - Proxy service with 9 methods - Advisor service with 5 methods - Sites service with 25 methods @@ -45,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Teams service with 18 methods - Tokens service with 5 methods - Users service with 50 methods +- VectorsDB service with 36 methods - Webhooks service with 6 methods ### Services @@ -192,6 +197,9 @@ You can use the color and background params to change the avatar colors. By defa When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. +- `get_photo()` - Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. + +The photo resolves for the currently authenticated user unless `userId` points at another user. Passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the user's own identity photos, email, and name leave the chain so they never shadow the avatar being asked for. Emails are only ever accepted pre-hashed, so no address ends up in a URL. - `get_qr()` - Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. - `get_screenshot()` - Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -328,6 +336,49 @@ Attributes can be `key`, `fulltext`, and `unique`. - `get_index()` - Get an index by its unique ID. - `delete_index()` - Delete an index. +#### DocumentsDB + +- `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. +- `create()` - Create a new Database. + +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. +- `list_transactions()` - List transactions across all databases. +- `create_transaction()` - Create a new transaction. +- `get_transaction()` - Get a transaction by its unique ID. +- `update_transaction()` - Update a transaction, to either commit or roll back its operations. +- `delete_transaction()` - Delete a transaction by its unique ID. +- `create_operations()` - Create multiple operations in a single transaction. +- `get()` - Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. +- `update()` - Update a database by its unique ID. +- `delete()` - Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. +- `list_collections()` - Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. +- `create_collection()` - Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `get_collection()` - Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. +- `update_collection()` - Update a collection by its unique ID. +- `delete_collection()` - Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. +- `list_documents()` - Get a list of all the user's documents in a given collection. You can use the query params to filter your results. +- `create_document()` - Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `create_documents()` - Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `upsert_documents()` - Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + +- `update_documents()` - Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. +- `delete_documents()` - Bulk delete documents using queries, if no queries are passed then all documents are deleted. +- `get_document()` - Get a document by its unique ID. This endpoint response returns a JSON object with the document data. +- `upsert_document()` - Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `update_document()` - Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. +- `delete_document()` - Delete a document by its unique ID. +- `decrement_document_attribute()` - Decrement a specific column of a row by a given value. +- `increment_document_attribute()` - Increment a specific column of a row by a given value. +- `list_indexes()` - List indexes in the collection. +- `create_index()` - Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. +Attributes can be `key`, `fulltext`, and `unique`. +- `get_index()` - Get index by ID. +- `delete_index()` - Delete an index. +- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. +- `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. +- `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. +- `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + #### Embeddings - `create_text_embeddings()` - Generate vector embeddings for an array of text using the selected embedding model. Use the returned vectors to power semantic search and similarity queries against your vector collections. @@ -454,6 +505,77 @@ The Messaging service allows you to send messages to any provider type (SMTP, pu - `delete_subscriber()` - Delete a subscriber by its unique ID. +#### Mongo + +- `list()` - List all dedicated databases. Results support pagination. +- `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. +- `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. +- `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. +- `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. +- `list_backups()` - List all backups for a dedicated database. Results can be filtered by status and type. +- `create_backup()` - Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. +- `list_backup_policies()` - List scheduled backup policies for a dedicated database. +- `create_backup_policy()` - Create a scheduled backup policy for a dedicated database. +- `get_backup_policy()` - Get a scheduled backup policy for a dedicated database. +- `update_backup_policy()` - Update a scheduled backup policy for a dedicated database. +- `delete_backup_policy()` - Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. +- `update_backup_storage()` - Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. +- `get_backup()` - Get details of a specific database backup including its status, size, and timestamps. +- `delete_backup()` - Delete a database backup. This will permanently remove the backup from storage and cannot be undone. +- `list_branches()` - List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. +- `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. +- `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. +- `update_credentials()` - Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. +- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. +- `update_maintenance()` - Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. +- `create_migration()` - Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. +- `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. +- `get_pitr()` - Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. +- `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. +- `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. +- `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. +- `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +- `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + +#### Mysql + +- `list()` - List all dedicated databases. Results support pagination. +- `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. +- `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. +- `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. +- `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. +- `list_backups()` - List all backups for a dedicated database. Results can be filtered by status and type. +- `create_backup()` - Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. +- `list_backup_policies()` - List scheduled backup policies for a dedicated database. +- `create_backup_policy()` - Create a scheduled backup policy for a dedicated database. +- `get_backup_policy()` - Get a scheduled backup policy for a dedicated database. +- `update_backup_policy()` - Update a scheduled backup policy for a dedicated database. +- `delete_backup_policy()` - Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. +- `update_backup_storage()` - Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. +- `get_backup()` - Get details of a specific database backup including its status, size, and timestamps. +- `delete_backup()` - Delete a database backup. This will permanently remove the backup from storage and cannot be undone. +- `list_branches()` - List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. +- `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. +- `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. +- `update_credentials()` - Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. +- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. +- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. +- `update_maintenance()` - Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. +- `create_migration()` - Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. +- `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. +- `get_pitr()` - Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. +- `get_pooler()` - Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. +- `update_pooler()` - Update the connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. +- `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. +- `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. +- `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. +- `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +- `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + #### Oauth2 The OAuth2 service allows you to authorize apps and issue standards-based OAuth2 and OpenID Connect tokens. - `approve()` - Approve an OAuth2 grant after the user gives consent. Returns the `redirectUrl` the end user should be sent to. The consent screen may optionally pass enriched `authorization_details` to record the concrete resources the user selected. You can pass Accept header of `application/json` to receive a JSON response instead of a redirect. @@ -495,6 +617,46 @@ The Organization service allows you to manage organization-level projects. - `update_project()` - Update a project by its unique ID. - `delete_project()` - Delete a project by its unique ID. +#### Postgresql + +- `list()` - List all dedicated databases. Results support pagination. +- `create()` - Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready. +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. +- `get()` - Get a dedicated database by its unique ID. Returns the database configuration and current status. +- `update()` - Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place. +- `delete()` - Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup. +- `list_backups()` - List all backups for a dedicated database. Results can be filtered by status and type. +- `create_backup()` - Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint. +- `list_backup_policies()` - List scheduled backup policies for a dedicated database. +- `create_backup_policy()` - Create a scheduled backup policy for a dedicated database. +- `get_backup_policy()` - Get a scheduled backup policy for a dedicated database. +- `update_backup_policy()` - Update a scheduled backup policy for a dedicated database. +- `delete_backup_policy()` - Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires. +- `update_backup_storage()` - Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage. +- `get_backup()` - Get details of a specific database backup including its status, size, and timestamps. +- `delete_backup()` - Delete a database backup. This will permanently remove the backup from storage and cannot be undone. +- `list_branches()` - List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time. +- `create_branch()` - Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously. +- `delete_branch()` - Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible. +- `update_credentials()` - Rotate the primary connection credentials for a dedicated database. Generates a new password and updates the database atomically. Previous credentials stop working immediately. Returns the database with a refreshed connection string carrying the new password. +- `create_execution()` - Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. +- `list_extensions()` - List installed and available extensions for a PostgreSQL database. +- `create_extension()` - Install a database extension. Only available for PostgreSQL databases. The install runs asynchronously; poll the extensions list endpoint for status. +- `delete_extension()` - Uninstall a database extension from a PostgreSQL database. The uninstall runs asynchronously; poll the extensions list endpoint for status. +- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. +- `update_maintenance()` - Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window. +- `create_migration()` - Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover. +- `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. +- `get_pitr()` - Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points. +- `get_pooler()` - Get the connection pooler configuration for a dedicated database. Returns pooler mode, max connections, and pool size settings. +- `update_pooler()` - Update the connection pooler configuration for a dedicated database. Configure pool mode, max connections, and pool sizes. +- `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. +- `list_restorations()` - List all restorations for a dedicated database. Results can be filtered by status and type. +- `create_restoration()` - Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. +- `get_restoration()` - Get details of a specific database restoration including its status, type, and timestamps. +- `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. +- `create_upgrade()` - Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover. + #### Presences The Presences service allows you to track and manage real-time user presence in your project. - `list()` - List presence logs. Expired entries are filtered out automatically. @@ -548,6 +710,7 @@ You can also create a standard API key if you need a longer-lived key instead. - `update_o_auth2_git_hub()` - Update the project OAuth2 GitHub configuration. - `update_o_auth2_gitlab()` - Update the project OAuth2 Gitlab configuration. - `update_o_auth2_google()` - Update the project OAuth2 Google configuration. +- `update_o_auth2_hugging_face()` - Update the project OAuth2 Hugging Face configuration. - `update_o_auth2_keycloak()` - Update the project OAuth2 Keycloak configuration. - `update_o_auth2_kick()` - Update the project OAuth2 Kick configuration. - `update_o_auth2_linkedin()` - Update the project OAuth2 Linkedin configuration. @@ -722,7 +885,7 @@ The TablesDB service allows you to create structured tables of columns, query an - `get()` - Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. - `update()` - Update a database by its unique ID. - `delete()` - Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. -- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation by a failover that did not finish also accepts this call as a repair, provided `targetReplicaId` names the member to promote. +- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. - `list_migrations()` - List the dedicated migrations for a TablesDB database. A database has at most one in-flight migration. - `create_migration()` - Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. - `get_migration()` - Get a single dedicated migration for a TablesDB database by its ID. @@ -919,6 +1082,49 @@ If you want to generate a token for a custom authentication flow, use the [POST - `update_email_verification()` - Update the user email verification status by its unique ID. - `update_phone_verification()` - Update the user phone verification status by its unique ID. +#### VectorsDB + +- `list()` - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. +- `create()` - Create a new Database. + +- `list_specifications()` - List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. +- `list_transactions()` - List transactions across all databases. +- `create_transaction()` - Create a new transaction. +- `get_transaction()` - Get a transaction by its unique ID. +- `update_transaction()` - Update a transaction, to either commit or roll back its operations. +- `delete_transaction()` - Delete a transaction by its unique ID. +- `create_operations()` - Create multiple operations in a single transaction. +- `get()` - Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. +- `update()` - Update a database by its unique ID. +- `delete()` - Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. +- `list_collections()` - Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. +- `create_collection()` - Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `get_collection()` - Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. +- `update_collection()` - Update a collection by its unique ID. +- `delete_collection()` - Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. +- `list_documents()` - Get a list of all the user's documents in a given collection. You can use the query params to filter your results. +- `create_document()` - Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `create_documents()` - Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `upsert_documents()` - Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + +- `update_documents()` - Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. +- `delete_documents()` - Bulk delete documents using queries, if no queries are passed then all documents are deleted. +- `create_query()` - Get a list of all the user's documents in a given collection using a POST request. This behaves identically to the list documents endpoint but accepts the queries in the request body, allowing much larger `queries` arrays than can fit in a URL query string. + +- `get_document()` - Get a document by its unique ID. This endpoint response returns a JSON object with the document data. +- `upsert_document()` - Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. +- `update_document()` - Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. +- `delete_document()` - Delete a document by its unique ID. +- `list_indexes()` - List indexes in the collection. +- `create_index()` - Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. +Attributes can be `key`, `fulltext`, and `unique`. +- `get_index()` - Get index by ID. +- `delete_index()` - Delete an index. +- `create_failover()` - Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a `failed` database, a stranded upgrade or migrate, or a stranded compute resize additionally requires `targetReplicaId` to name the member to promote, because the default target may be the member that operation already promoted. +- `list_operations()` - List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database. +- `get_replicas()` - Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode. +- `get_status()` - Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information. + #### Webhooks The Webhooks service allows you to manage your project webhooks. - `list()` - Get a list of all webhooks belonging to the project. You can use the query params to filter your results. @@ -974,6 +1180,7 @@ The Webhooks service allows you to manage your project webhooks. - `TargetList` - Target list - `TransactionList` - Transaction List - `SpecificationList` - Specifications List +- `VectorsdbCollectionList` - VectorsDB Collections List - `EmbeddingList` - Embedding list - `InsightList` - Insights List - `ReportList` - Reports List @@ -999,6 +1206,9 @@ The Webhooks service allows you to manage your project webhooks. - `AttributeText` - AttributeText - `AttributeMediumtext` - AttributeMediumtext - `AttributeLongtext` - AttributeLongtext +- `VectorsdbCollection` - VectorsDB Collection +- `AttributeObject` - AttributeObject +- `AttributeVector` - AttributeVector - `Table` - Table - `ColumnList` - Columns List - `ColumnString` - ColumnString @@ -1084,6 +1294,7 @@ The Webhooks service allows you to manage your project webhooks. - `OAuth2Notion` - OAuth2Notion - `OAuth2Salesforce` - OAuth2Salesforce - `OAuth2Yahoo` - OAuth2Yahoo +- `OAuth2HuggingFace` - OAuth2HuggingFace - `OAuth2Linkedin` - OAuth2Linkedin - `OAuth2Disqus` - OAuth2Disqus - `OAuth2Amazon` - OAuth2Amazon @@ -1147,6 +1358,9 @@ The Webhooks service allows you to manage your project webhooks. - `ActivityEvent` - ActivityEvent - `AdditionalResource` - AdditionalResource - `BackupArchive` - Archive +- `DedicatedDatabaseBackup` - Backup +- `DedicatedDatabaseBackupList` - BackupList +- `DedicatedDatabaseBackupStorage` - BackupStorageConfig - `BillingLimits` - Limits - `BillingPlan` - billingPlan - `BillingPlanAddon` - Addon @@ -1155,22 +1369,32 @@ The Webhooks service allows you to manage your project webhooks. - `BillingPlanDedicatedDatabaseLimits` - dedicatedDatabaseLimits - `BillingPlanSupportedAddons` - BillingPlanSupportedAddons - `Block` - Block +- `DedicatedDatabaseBranch` - Branch +- `DedicatedDatabaseBranchList` - BranchList - `DatabaseMigration` - Database Migration - `DedicatedDatabase` - DedicatedDatabase +- `DedicatedDatabaseExecution` - Execution +- `DedicatedDatabaseExecutionColumn` - ExecutionColumn +- `DedicatedDatabaseRestoration` - Restoration - `DatabaseStatus` - Status +- `DedicatedDatabaseExtensions` - Extensions - `DedicatedDatabaseMember` - Member - `DedicatedDatabaseOperation` - Operation - `DedicatedDatabaseOperationList` - OperationList - `DedicatedDatabaseReplicas` - Replicas - `ProxyInvalidation` - Invalidation - `Organization` - Organization +- `DedicatedDatabasePITRWindows` - PITRWindows - `BackupPolicy` - backup - `PolicyDenyAliasedEmail` - Policy Deny Aliased Email - `PolicyDenyDisposableEmail` - Policy Deny Disposable Email - `PolicyDenyFreeEmail` - Policy Deny Free Email - `PolicyDenyCorporateEmail` - Policy Deny Corporate Email +- `DedicatedDatabasePooler` - PoolerConfig +- `PostgresExtension` - Postgres extension - `Program` - Program - `BackupRestoration` - Restoration +- `DedicatedDatabaseRestorationList` - Dedicated database restorations list - `DedicatedDatabaseSpecification` - Specification - `DedicatedDatabaseSpecificationList` - SpecificationList - `DedicatedDatabaseSpecificationPricing` - SpecificationPricing @@ -1204,6 +1428,7 @@ The Webhooks service allows you to manage your project webhooks. - `BackupPolicyList` - Backup policy list - `BackupRestorationList` - Backup restoration list - `DatabaseMigrationList` - Database Migrations List +- `DedicatedDatabaseList` - Dedicated databases list - `AppsList` - Apps list - `AppSecretList` - App secrets list - `AppScopeList` - App scopes list @@ -1224,4 +1449,4 @@ The Webhooks service allows you to manage your project webhooks. - File upload examples - Query builder documentation -[0.13.0]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.13.0 +[0.14.0-rc.1]: https://github.com/appwrite/sdk-for-rust/releases/tag/0.14.0-rc.1 diff --git a/Cargo.toml b/Cargo.toml index b070ce2..8b90408 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "appwrite" -version = "0.13.0" +version = "0.14.0-rc.1" edition = "2021" rust-version = "1.83" authors = ["appwrite"] @@ -37,7 +37,7 @@ security-framework = ">=3, <3.7" [dev-dependencies] tokio-test = "=0.4.4" -wiremock = "=0.5.22" +wiremock = "=0.6.4" [lib] name = "appwrite" diff --git a/README.md b/README.md index 1a9a635..efef300 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -appwrite = "0.13.0" +appwrite = "0.14.0-rc.1" tokio = { version = "1.48", features = ["full"] } ``` diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 4720975..eaae6ff 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(0), // optional Some(0), // optional - Some("") // optional + Some("FFFFFF") // optional ).await?; let _ = result; diff --git a/docs/examples/avatars/get-photo.md b/docs/examples/avatars/get-photo.md new file mode 100644 index 0000000..0405838 --- /dev/null +++ b/docs/examples/avatars/get-photo.md @@ -0,0 +1,29 @@ +```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); + + let result = avatars.get_photo( + Some(0), // optional + Some(0), // optional + Some(0), // optional + Some("png"), // optional + Some("g"), // optional + Some("current()"), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md index c6d91a8..6c8f09d 100644 --- a/docs/examples/databases/create-big-int-attribute.md +++ b/docs/examples/databases/create-big-int-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.create_big_int_attribute( "", "", - "", + "", false, Some(0), // optional - Some(0), // optional + Some(1000000), // optional Some(0), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 3321021..b109079 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_boolean_attribute( "", "", - "", + "", false, Some(false), // optional Some(false) // optional diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index b88be51..736f80c 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_datetime_attribute( "", "", - "", + "", false, Some("2020-10-15T06:38:00.000+00:00"), // optional Some(false) // optional diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 481b943..cdebbb4 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_email_attribute( "", "", - "", + "", false, Some("email@example.com"), // optional Some(false) // optional diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 5ab0523..edaf6a8 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.create_enum_attribute( "", "", - "", - vec![], + "", + vec!["active".into(), "inactive".into()], false, - Some(""), // optional + Some("active"), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index 4d8a8da..2f1faf5 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = databases.create_float_attribute( "", "", - "", + "", false, Some(0), // optional - Some(0), // optional - Some(0), // optional + Some(100), // optional + Some(10.5), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 1145097..b7389d9 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_index( "", "", - "", + "", appwrite::enums::DatabasesIndexType::Key, vec![], Some(vec![appwrite::enums::OrderBy::Asc]), // optional diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index 481a8ce..7d2d1b1 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = databases.create_integer_attribute( "", "", - "", + "", false, Some(0), // optional - Some(0), // optional - Some(0), // optional + Some(100), // optional + Some(10), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 42523f2..9ab3d7c 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = databases.create_ip_attribute( "", "", - "", + "", false, - Some(""), // optional + Some("192.0.2.0"), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index f0adbaa..d0834b1 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_line_attribute( "", "", - "", + "", false, Some(vec![serde_json::json!([1,2]), serde_json::json!([3,4]), serde_json::json!([5,6])]) // optional ).await?; diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md index e92114f..11a38c1 100644 --- a/docs/examples/databases/create-longtext-attribute.md +++ b/docs/examples/databases/create-longtext-attribute.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = databases.create_longtext_attribute( "", "", - "", + "", false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md index 8baaea4..328414b 100644 --- a/docs/examples/databases/create-mediumtext-attribute.md +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = databases.create_mediumtext_attribute( "", "", - "", + "", false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index dc7f9fc..489fba3 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_point_attribute( "", "", - "", + "", false, Some(vec![1, 2]) // optional ).await?; diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 6f75070..32c519f 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_polygon_attribute( "", "", - "", + "", false, Some(vec![serde_json::json!([[1,2],[3,4],[5,6],[1,2]])]) // optional ).await?; diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 84c4947..af202d4 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -17,8 +17,8 @@ async fn main() -> Result<(), Box> { "", appwrite::enums::RelationshipType::OneToOne, Some(false), // optional - Some(""), // optional - Some(""), // optional + Some(""), // optional + Some(""), // optional Some(appwrite::enums::RelationMutate::Cascade) // optional ).await?; diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index f46f799..30ed03b 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.create_string_attribute( "", "", - "", + "", 1, false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md index 370d32a..6f0b142 100644 --- a/docs/examples/databases/create-text-attribute.md +++ b/docs/examples/databases/create-text-attribute.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = databases.create_text_attribute( "", "", - "", + "", false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index ad75f4e..6a9b96f 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.create_url_attribute( "", "", - "", + "", false, Some("https://example.com"), // optional Some(false) // optional diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md index 5a0bffc..66528ae 100644 --- a/docs/examples/databases/create-varchar-attribute.md +++ b/docs/examples/databases/create-varchar-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.create_varchar_attribute( "", "", - "", + "", 1, false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 5d373be..8dd9d18 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -15,8 +15,8 @@ async fn main() -> Result<(), Box> { "", "", "", - "", - Some(0), // optional + "", + Some(1), // optional Some(0), // optional Some("") // optional ).await?; diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index 7cda5ec..3388f0b 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { databases.delete_attribute( "", "", - "" + "" ).await?; Ok(()) diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 7465144..49ae6eb 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { databases.delete_index( "", "", - "" + "" ).await?; Ok(()) diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index ef118d2..6053bdf 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.get_attribute( "", "", - "" + "" ).await?; let _ = result; diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index d9bce54..7a7ea73 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = databases.get_index( "", "", - "" + "" ).await?; let _ = result; diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 7b403bd..36f3ea1 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -15,9 +15,9 @@ async fn main() -> Result<(), Box> { "", "", "", - "", - Some(0), // optional - Some(0), // optional + "", + Some(1), // optional + Some(100), // optional Some("") // optional ).await?; diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md index 0f221bf..eafd1dd 100644 --- a/docs/examples/databases/update-big-int-attribute.md +++ b/docs/examples/databases/update-big-int-attribute.md @@ -14,12 +14,12 @@ async fn main() -> Result<(), Box> { let result = databases.update_big_int_attribute( "", "", - "", + "", false, Some(0), Some(0), // optional - Some(0), // optional - Some("") // optional + Some(1000000), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index b3477b3..9e9e551 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_boolean_attribute( "", "", - "", + "", false, Some(false), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index 0f431d1..b0ce51f 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_datetime_attribute( "", "", - "", + "", false, Some("2020-10-15T06:38:00.000+00:00"), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index 417681b..51da9ad 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_email_attribute( "", "", - "", + "", false, Some("email@example.com"), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 66d5e71..07f9ea3 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = databases.update_enum_attribute( "", "", - "", - vec![], + "", + vec!["active".into(), "inactive".into()], false, - Some(""), - Some("") // optional + Some("active"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index e63c364..4ce1b3d 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -14,12 +14,12 @@ async fn main() -> Result<(), Box> { let result = databases.update_float_attribute( "", "", - "", + "", false, - Some(0), + Some(10.5), Some(0), // optional - Some(0), // optional - Some("") // optional + Some(100), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 9e6d0bc..d9a912e 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -14,12 +14,12 @@ async fn main() -> Result<(), Box> { let result = databases.update_integer_attribute( "", "", - "", + "", false, - Some(0), + Some(10), Some(0), // optional - Some(0), // optional - Some("") // optional + Some(100), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 7f3416e..3912aa9 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_ip_attribute( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("192.0.2.0"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index 4e4c0f9..8ba8127 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_line_attribute( "", "", - "", + "", false, Some(vec![serde_json::json!([1,2]), serde_json::json!([3,4]), serde_json::json!([5,6])]), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md index 3936d90..dc6dabc 100644 --- a/docs/examples/databases/update-longtext-attribute.md +++ b/docs/examples/databases/update-longtext-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_longtext_attribute( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("Hello World"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md index e208ed7..f88d43b 100644 --- a/docs/examples/databases/update-mediumtext-attribute.md +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_mediumtext_attribute( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("Hello World"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 1669c24..b862fd6 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_point_attribute( "", "", - "", + "", false, Some(vec![1, 2]), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index 453fe76..541b17b 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_polygon_attribute( "", "", - "", + "", false, Some(vec![serde_json::json!([[1,2],[3,4],[5,6],[1,2]])]), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 5eedeac..d8a3073 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = databases.update_relationship_attribute( "", "", - "", + "", Some(appwrite::enums::RelationMutate::Cascade), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index d30640a..5238097 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = databases.update_string_attribute( "", "", - "", + "", false, - Some(""), + Some("Hello World"), Some(1), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md index eaf9a17..646ccec 100644 --- a/docs/examples/databases/update-text-attribute.md +++ b/docs/examples/databases/update-text-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_text_attribute( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("Hello World"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 5d384f5..ca80799 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = databases.update_url_attribute( "", "", - "", + "", false, Some("https://example.com"), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md index 5ca0b24..bda6271 100644 --- a/docs/examples/databases/update-varchar-attribute.md +++ b/docs/examples/databases/update-varchar-attribute.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = databases.update_varchar_attribute( "", "", - "", + "", false, - Some(""), + Some("Hello World"), Some(1), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md new file mode 100644 index 0000000..8e7eb00 --- /dev/null +++ b/docs/examples/documentsdb/create-collection.md @@ -0,0 +1,31 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_collection( + "", + "", + "", + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some(false), // optional + Some(false), // optional + Some(vec![]), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md new file mode 100644 index 0000000..4e34382 --- /dev/null +++ b/docs/examples/documentsdb/create-document.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_document( + "", + "", + "", + serde_json::json!({}), + Some(vec![Permission::read(Role::any()).to_string()]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md new file mode 100644 index 0000000..b1a2d1e --- /dev/null +++ b/docs/examples/documentsdb/create-documents.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_documents( + "", + "", + vec![] + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create-failover.md b/docs/examples/documentsdb/create-failover.md new file mode 100644 index 0000000..9c22257 --- /dev/null +++ b/docs/examples/documentsdb/create-failover.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_failover( + "", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md new file mode 100644 index 0000000..2b7534c --- /dev/null +++ b/docs/examples/documentsdb/create-index.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_index( + "", + "", + "", + appwrite::enums::DocumentsDBIndexType::Key, + vec![], + Some(vec![appwrite::enums::OrderBy::Asc]), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md new file mode 100644 index 0000000..4288bfb --- /dev/null +++ b/docs/examples/documentsdb/create-operations.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_operations( + "", + Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"name":"Walter O'Brien"}})]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md new file mode 100644 index 0000000..46ba2c1 --- /dev/null +++ b/docs/examples/documentsdb/create-transaction.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create_transaction( + Some(60) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md new file mode 100644 index 0000000..7931993 --- /dev/null +++ b/docs/examples/documentsdb/create.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.create( + "", + "", + Some(false), // optional + Some("serverless"), // optional + Some(0), // optional + Some("async") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md new file mode 100644 index 0000000..31453e7 --- /dev/null +++ b/docs/examples/documentsdb/decrement-document-attribute.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.decrement_document_attribute( + "", + "", + "", + "", + Some(1), // optional + Some(0), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md new file mode 100644 index 0000000..777bc9f --- /dev/null +++ b/docs/examples/documentsdb/delete-collection.md @@ -0,0 +1,21 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + documents_db.delete_collection( + "", + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md new file mode 100644 index 0000000..aaf1c97 --- /dev/null +++ b/docs/examples/documentsdb/delete-document.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + documents_db.delete_document( + "", + "", + "", + Some("") // optional + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md new file mode 100644 index 0000000..be2ad02 --- /dev/null +++ b/docs/examples/documentsdb/delete-documents.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.delete_documents( + "", + "", + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md new file mode 100644 index 0000000..d2911ca --- /dev/null +++ b/docs/examples/documentsdb/delete-index.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + documents_db.delete_index( + "", + "", + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md new file mode 100644 index 0000000..86a7d3d --- /dev/null +++ b/docs/examples/documentsdb/delete-transaction.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + documents_db.delete_transaction( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md new file mode 100644 index 0000000..f0254c3 --- /dev/null +++ b/docs/examples/documentsdb/delete.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + documents_db.delete( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md new file mode 100644 index 0000000..742ada7 --- /dev/null +++ b/docs/examples/documentsdb/get-collection.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get_collection( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md new file mode 100644 index 0000000..b2c1ca5 --- /dev/null +++ b/docs/examples/documentsdb/get-document.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get_document( + "", + "", + "", + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md new file mode 100644 index 0000000..cd4ffbd --- /dev/null +++ b/docs/examples/documentsdb/get-index.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get_index( + "", + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get-replicas.md b/docs/examples/documentsdb/get-replicas.md new file mode 100644 index 0000000..a00d5cd --- /dev/null +++ b/docs/examples/documentsdb/get-replicas.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get_replicas( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get-status.md b/docs/examples/documentsdb/get-status.md new file mode 100644 index 0000000..c5f38fe --- /dev/null +++ b/docs/examples/documentsdb/get-status.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get_status( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md new file mode 100644 index 0000000..2a7ade6 --- /dev/null +++ b/docs/examples/documentsdb/get-transaction.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get_transaction( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md new file mode 100644 index 0000000..e60770c --- /dev/null +++ b/docs/examples/documentsdb/get.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.get( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md new file mode 100644 index 0000000..f45a1bb --- /dev/null +++ b/docs/examples/documentsdb/increment-document-attribute.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.increment_document_attribute( + "", + "", + "", + "", + Some(1), // optional + Some(100), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md new file mode 100644 index 0000000..2266a73 --- /dev/null +++ b/docs/examples/documentsdb/list-collections.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list_collections( + "", + Some(vec![]), // optional + Some(""), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md new file mode 100644 index 0000000..b99a9fd --- /dev/null +++ b/docs/examples/documentsdb/list-documents.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list_documents( + "", + "", + Some(vec![]), // optional + Some(""), // optional + Some(false), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md new file mode 100644 index 0000000..0db1c7a --- /dev/null +++ b/docs/examples/documentsdb/list-indexes.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list_indexes( + "", + "", + Some(vec![]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list-operations.md b/docs/examples/documentsdb/list-operations.md new file mode 100644 index 0000000..e39d7ef --- /dev/null +++ b/docs/examples/documentsdb/list-operations.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list_operations( + "", + Some("queued"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list-specifications.md b/docs/examples/documentsdb/list-specifications.md new file mode 100644 index 0000000..7ec4b01 --- /dev/null +++ b/docs/examples/documentsdb/list-specifications.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list_specifications().await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md new file mode 100644 index 0000000..9f387f6 --- /dev/null +++ b/docs/examples/documentsdb/list-transactions.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list_transactions( + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md new file mode 100644 index 0000000..f67a70f --- /dev/null +++ b/docs/examples/documentsdb/list.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.list( + Some(vec![]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md new file mode 100644 index 0000000..8954616 --- /dev/null +++ b/docs/examples/documentsdb/update-collection.md @@ -0,0 +1,30 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.update_collection( + "", + "", + "", + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some(false), // optional + Some(false), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md new file mode 100644 index 0000000..6faab5b --- /dev/null +++ b/docs/examples/documentsdb/update-document.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.update_document( + "", + "", + "", + Some(serde_json::json!({})), // optional + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md new file mode 100644 index 0000000..a850392 --- /dev/null +++ b/docs/examples/documentsdb/update-documents.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.update_documents( + "", + "", + Some(serde_json::json!({})), // optional + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md new file mode 100644 index 0000000..449d187 --- /dev/null +++ b/docs/examples/documentsdb/update-transaction.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.update_transaction( + "", + Some(false), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md new file mode 100644 index 0000000..0ac5fcf --- /dev/null +++ b/docs/examples/documentsdb/update.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.update( + "", + "", + Some(false), // optional + Some("serverless"), // optional + Some(0), // optional + Some("async") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md new file mode 100644 index 0000000..29e6d53 --- /dev/null +++ b/docs/examples/documentsdb/upsert-document.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.upsert_document( + "", + "", + "", + Some(serde_json::json!({})), // optional + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md new file mode 100644 index 0000000..d6ba165 --- /dev/null +++ b/docs/examples/documentsdb/upsert-documents.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::DocumentsDB; + +#[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 documents_db = DocumentsDB::new(&client); + + let result = documents_db.upsert_documents( + "", + "", + vec![], + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index cea46ea..46b7a20 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { appwrite::enums::Runtime::Node145, Some(vec!["any".into()]), // optional Some(vec![]), // optional - Some(""), // optional + Some("0 0 * * *"), // optional Some(1), // optional Some(false), // optional Some(false), // optional @@ -31,8 +31,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(vec![]), // optional Some(vec![]), // optional - Some(""), // optional - Some(""), // optional + Some("s-1vcpu-512mb"), // optional + Some("s-1vcpu-512mb"), // optional Some(0) // optional ).await?; diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2eec7ae..16e4ea5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { Some(appwrite::enums::Runtime::Node145), // optional Some(vec!["any".into()]), // optional Some(vec![]), // optional - Some(""), // optional + Some("0 0 * * *"), // optional Some(1), // optional Some(false), // optional Some(false), // optional @@ -31,8 +31,8 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(vec![]), // optional Some(vec![]), // optional - Some(""), // optional - Some(""), // optional + Some("s-1vcpu-512mb"), // optional + Some("s-1vcpu-512mb"), // optional Some(0) // optional ).await?; diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index a3bb30c..ecc599c 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "", Some(""), // optional - Some(""), // optional + Some("example.com"), // optional Some(false), // optional Some(""), // optional Some("email@example.com"), // optional diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 5262d39..7f93d6b 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -25,7 +25,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(0), // optional + Some(1), // optional Some(false), // optional Some("2020-10-15T06:38:00.000+00:00"), // optional Some(false), // optional diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 37dfb17..f6ee6a1 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", "", "", - Some(1), // optional + Some(587), // optional Some(""), // optional Some("password"), // optional Some(appwrite::enums::SmtpEncryption::None), // optional diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index 56cca3a..60a710b 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { "", Some(""), // optional Some(""), // optional - Some(""), // optional + Some("example.com"), // optional Some(false), // optional Some(false), // optional Some(""), // optional diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index a24e71f..00fdc77 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -25,7 +25,7 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(""), // optional Some(""), // optional - Some(0), // optional + Some(1), // optional Some(false), // optional Some("2020-10-15T06:38:00.000+00:00"), // optional Some(false), // optional diff --git a/docs/examples/mongo/create-backup-policy.md b/docs/examples/mongo/create-backup-policy.md new file mode 100644 index 0000000..2b279cb --- /dev/null +++ b/docs/examples/mongo/create-backup-policy.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_backup_policy( + "", + "", + "", + "", + 1, + Some("full"), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create-backup.md b/docs/examples/mongo/create-backup.md new file mode 100644 index 0000000..70c484a --- /dev/null +++ b/docs/examples/mongo/create-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_backup( + "", + Some("full") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create-branch.md b/docs/examples/mongo/create-branch.md new file mode 100644 index 0000000..c510878 --- /dev/null +++ b/docs/examples/mongo/create-branch.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_branch( + "", + Some(""), // optional + Some(300) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create-failover.md b/docs/examples/mongo/create-failover.md new file mode 100644 index 0000000..d803e92 --- /dev/null +++ b/docs/examples/mongo/create-failover.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_failover( + "", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create-migration.md b/docs/examples/mongo/create-migration.md new file mode 100644 index 0000000..7cf12e5 --- /dev/null +++ b/docs/examples/mongo/create-migration.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_migration( + "", + "shared", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md new file mode 100644 index 0000000..2e93a7a --- /dev/null +++ b/docs/examples/mongo/create-restoration.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_restoration( + "", + Some("backup"), // optional + Some(""), // optional + Some(""), // optional + Some("2020-10-15T06:38:00.000+00:00") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create-upgrade.md b/docs/examples/mongo/create-upgrade.md new file mode 100644 index 0000000..b57fc68 --- /dev/null +++ b/docs/examples/mongo/create-upgrade.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create_upgrade( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/create.md b/docs/examples/mongo/create.md new file mode 100644 index 0000000..0a08eaa --- /dev/null +++ b/docs/examples/mongo/create.md @@ -0,0 +1,35 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.create( + "", + "", + Some("17"), // optional + Some(""), // optional + Some(0), // optional + Some("async"), // optional + Some(60), // optional + Some(vec![]), // optional + Some(5), // optional + Some(false), // optional + Some(1), // optional + Some(false), // optional + Some(50), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md new file mode 100644 index 0000000..9114d69 --- /dev/null +++ b/docs/examples/mongo/delete-backup-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.delete_backup_policy( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md new file mode 100644 index 0000000..d596d40 --- /dev/null +++ b/docs/examples/mongo/delete-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.delete_backup( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/delete-branch.md b/docs/examples/mongo/delete-branch.md new file mode 100644 index 0000000..27e9ad4 --- /dev/null +++ b/docs/examples/mongo/delete-branch.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.delete_branch( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md new file mode 100644 index 0000000..777f263 --- /dev/null +++ b/docs/examples/mongo/delete.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.delete( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get-backup-policy.md b/docs/examples/mongo/get-backup-policy.md new file mode 100644 index 0000000..adccb82 --- /dev/null +++ b/docs/examples/mongo/get-backup-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get_backup_policy( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get-backup.md b/docs/examples/mongo/get-backup.md new file mode 100644 index 0000000..53de16c --- /dev/null +++ b/docs/examples/mongo/get-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get_backup( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get-pitr.md b/docs/examples/mongo/get-pitr.md new file mode 100644 index 0000000..2182b5b --- /dev/null +++ b/docs/examples/mongo/get-pitr.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get_pitr( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get-replicas.md b/docs/examples/mongo/get-replicas.md new file mode 100644 index 0000000..cc94ec7 --- /dev/null +++ b/docs/examples/mongo/get-replicas.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get_replicas( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get-restoration.md b/docs/examples/mongo/get-restoration.md new file mode 100644 index 0000000..f1bc6e5 --- /dev/null +++ b/docs/examples/mongo/get-restoration.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get_restoration( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get-status.md b/docs/examples/mongo/get-status.md new file mode 100644 index 0000000..7271271 --- /dev/null +++ b/docs/examples/mongo/get-status.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get_status( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/get.md b/docs/examples/mongo/get.md new file mode 100644 index 0000000..0daad14 --- /dev/null +++ b/docs/examples/mongo/get.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.get( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list-backup-policies.md b/docs/examples/mongo/list-backup-policies.md new file mode 100644 index 0000000..3e3d461 --- /dev/null +++ b/docs/examples/mongo/list-backup-policies.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list_backup_policies( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list-backups.md b/docs/examples/mongo/list-backups.md new file mode 100644 index 0000000..7b6d7ee --- /dev/null +++ b/docs/examples/mongo/list-backups.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list_backups( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list-branches.md b/docs/examples/mongo/list-branches.md new file mode 100644 index 0000000..b276e17 --- /dev/null +++ b/docs/examples/mongo/list-branches.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list_branches( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list-operations.md b/docs/examples/mongo/list-operations.md new file mode 100644 index 0000000..07cabeb --- /dev/null +++ b/docs/examples/mongo/list-operations.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list_operations( + "", + Some("queued"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list-restorations.md b/docs/examples/mongo/list-restorations.md new file mode 100644 index 0000000..e45d130 --- /dev/null +++ b/docs/examples/mongo/list-restorations.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list_restorations( + "", + Some("pending"), // optional + Some("backup"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list-specifications.md b/docs/examples/mongo/list-specifications.md new file mode 100644 index 0000000..7083847 --- /dev/null +++ b/docs/examples/mongo/list-specifications.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list_specifications().await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/list.md b/docs/examples/mongo/list.md new file mode 100644 index 0000000..935e886 --- /dev/null +++ b/docs/examples/mongo/list.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.list( + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/update-backup-policy.md b/docs/examples/mongo/update-backup-policy.md new file mode 100644 index 0000000..ae7fe02 --- /dev/null +++ b/docs/examples/mongo/update-backup-policy.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.update_backup_policy( + "", + "", + Some(""), // optional + Some(""), // optional + Some(1), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/update-backup-storage.md b/docs/examples/mongo/update-backup-storage.md new file mode 100644 index 0000000..6fda526 --- /dev/null +++ b/docs/examples/mongo/update-backup-storage.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.update_backup_storage( + "", + "s3", + "", + "", + "", + Some(""), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/update-credentials.md b/docs/examples/mongo/update-credentials.md new file mode 100644 index 0000000..50ed2f6 --- /dev/null +++ b/docs/examples/mongo/update-credentials.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.update_credentials( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/update-maintenance.md b/docs/examples/mongo/update-maintenance.md new file mode 100644 index 0000000..b3cc199 --- /dev/null +++ b/docs/examples/mongo/update-maintenance.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.update_maintenance( + "", + "sun", + 0 + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md new file mode 100644 index 0000000..5d05c20 --- /dev/null +++ b/docs/examples/mongo/update.md @@ -0,0 +1,42 @@ +```rust +use appwrite::Client; +use appwrite::services::Mongo; + +#[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 mongo = Mongo::new(&client); + + let result = mongo.update( + "", + Some(""), // optional + Some("ready"), // optional + Some(""), // optional + Some(0), // optional + Some("async"), // optional + Some(60), // optional + Some(vec![]), // optional + Some(5), // optional + Some(false), // optional + Some(1), // optional + Some(false), // optional + Some(50), // optional + Some(0), // optional + Some(0), // optional + Some(0), // optional + Some(false), // optional + Some(vec![]), // optional + Some(1), // optional + Some(1024), // optional + Some(1) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-backup-policy.md b/docs/examples/mysql/create-backup-policy.md new file mode 100644 index 0000000..199f456 --- /dev/null +++ b/docs/examples/mysql/create-backup-policy.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_backup_policy( + "", + "", + "", + "", + 1, + Some("full"), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-backup.md b/docs/examples/mysql/create-backup.md new file mode 100644 index 0000000..d5dc08a --- /dev/null +++ b/docs/examples/mysql/create-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_backup( + "", + Some("full") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-branch.md b/docs/examples/mysql/create-branch.md new file mode 100644 index 0000000..d6e9a38 --- /dev/null +++ b/docs/examples/mysql/create-branch.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_branch( + "", + Some(""), // optional + Some(300) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-execution.md b/docs/examples/mysql/create-execution.md new file mode 100644 index 0000000..4d42ef2 --- /dev/null +++ b/docs/examples/mysql/create-execution.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_execution( + "", + "", + Some(serde_json::json!({})), // optional + Some(1) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-failover.md b/docs/examples/mysql/create-failover.md new file mode 100644 index 0000000..61413bb --- /dev/null +++ b/docs/examples/mysql/create-failover.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_failover( + "", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-migration.md b/docs/examples/mysql/create-migration.md new file mode 100644 index 0000000..d7f641c --- /dev/null +++ b/docs/examples/mysql/create-migration.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_migration( + "", + "shared", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md new file mode 100644 index 0000000..f194175 --- /dev/null +++ b/docs/examples/mysql/create-restoration.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_restoration( + "", + Some("backup"), // optional + Some(""), // optional + Some(""), // optional + Some("2020-10-15T06:38:00.000+00:00") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create-upgrade.md b/docs/examples/mysql/create-upgrade.md new file mode 100644 index 0000000..b9530f3 --- /dev/null +++ b/docs/examples/mysql/create-upgrade.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create_upgrade( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/create.md b/docs/examples/mysql/create.md new file mode 100644 index 0000000..0b58058 --- /dev/null +++ b/docs/examples/mysql/create.md @@ -0,0 +1,35 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.create( + "", + "", + Some("17"), // optional + Some(""), // optional + Some(0), // optional + Some("async"), // optional + Some(60), // optional + Some(vec![]), // optional + Some(5), // optional + Some(false), // optional + Some(1), // optional + Some(false), // optional + Some(50), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md new file mode 100644 index 0000000..39ae07e --- /dev/null +++ b/docs/examples/mysql/delete-backup-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.delete_backup_policy( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md new file mode 100644 index 0000000..2e0b931 --- /dev/null +++ b/docs/examples/mysql/delete-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.delete_backup( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/delete-branch.md b/docs/examples/mysql/delete-branch.md new file mode 100644 index 0000000..301c29f --- /dev/null +++ b/docs/examples/mysql/delete-branch.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.delete_branch( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md new file mode 100644 index 0000000..db5d332 --- /dev/null +++ b/docs/examples/mysql/delete.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.delete( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-backup-policy.md b/docs/examples/mysql/get-backup-policy.md new file mode 100644 index 0000000..2a93c6f --- /dev/null +++ b/docs/examples/mysql/get-backup-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_backup_policy( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-backup.md b/docs/examples/mysql/get-backup.md new file mode 100644 index 0000000..1b51767 --- /dev/null +++ b/docs/examples/mysql/get-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_backup( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-pitr.md b/docs/examples/mysql/get-pitr.md new file mode 100644 index 0000000..1f60498 --- /dev/null +++ b/docs/examples/mysql/get-pitr.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_pitr( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-pooler.md b/docs/examples/mysql/get-pooler.md new file mode 100644 index 0000000..d9d5c2d --- /dev/null +++ b/docs/examples/mysql/get-pooler.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_pooler( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-replicas.md b/docs/examples/mysql/get-replicas.md new file mode 100644 index 0000000..0522f7f --- /dev/null +++ b/docs/examples/mysql/get-replicas.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_replicas( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-restoration.md b/docs/examples/mysql/get-restoration.md new file mode 100644 index 0000000..a70fc66 --- /dev/null +++ b/docs/examples/mysql/get-restoration.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_restoration( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get-status.md b/docs/examples/mysql/get-status.md new file mode 100644 index 0000000..bc8d63d --- /dev/null +++ b/docs/examples/mysql/get-status.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get_status( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/get.md b/docs/examples/mysql/get.md new file mode 100644 index 0000000..29db2d2 --- /dev/null +++ b/docs/examples/mysql/get.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.get( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list-backup-policies.md b/docs/examples/mysql/list-backup-policies.md new file mode 100644 index 0000000..81fda83 --- /dev/null +++ b/docs/examples/mysql/list-backup-policies.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list_backup_policies( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list-backups.md b/docs/examples/mysql/list-backups.md new file mode 100644 index 0000000..3fbc9a2 --- /dev/null +++ b/docs/examples/mysql/list-backups.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list_backups( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list-branches.md b/docs/examples/mysql/list-branches.md new file mode 100644 index 0000000..78dc327 --- /dev/null +++ b/docs/examples/mysql/list-branches.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list_branches( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list-operations.md b/docs/examples/mysql/list-operations.md new file mode 100644 index 0000000..e9e1c35 --- /dev/null +++ b/docs/examples/mysql/list-operations.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list_operations( + "", + Some("queued"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list-restorations.md b/docs/examples/mysql/list-restorations.md new file mode 100644 index 0000000..0150bf9 --- /dev/null +++ b/docs/examples/mysql/list-restorations.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list_restorations( + "", + Some("pending"), // optional + Some("backup"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list-specifications.md b/docs/examples/mysql/list-specifications.md new file mode 100644 index 0000000..1b1d415 --- /dev/null +++ b/docs/examples/mysql/list-specifications.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list_specifications().await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/list.md b/docs/examples/mysql/list.md new file mode 100644 index 0000000..d0eab0a --- /dev/null +++ b/docs/examples/mysql/list.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.list( + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/update-backup-policy.md b/docs/examples/mysql/update-backup-policy.md new file mode 100644 index 0000000..0953c20 --- /dev/null +++ b/docs/examples/mysql/update-backup-policy.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.update_backup_policy( + "", + "", + Some(""), // optional + Some(""), // optional + Some(1), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/update-backup-storage.md b/docs/examples/mysql/update-backup-storage.md new file mode 100644 index 0000000..ead9dcd --- /dev/null +++ b/docs/examples/mysql/update-backup-storage.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.update_backup_storage( + "", + "s3", + "", + "", + "", + Some(""), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/update-credentials.md b/docs/examples/mysql/update-credentials.md new file mode 100644 index 0000000..cc8b16c --- /dev/null +++ b/docs/examples/mysql/update-credentials.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.update_credentials( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/update-maintenance.md b/docs/examples/mysql/update-maintenance.md new file mode 100644 index 0000000..e3f467a --- /dev/null +++ b/docs/examples/mysql/update-maintenance.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.update_maintenance( + "", + "sun", + 0 + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/update-pooler.md b/docs/examples/mysql/update-pooler.md new file mode 100644 index 0000000..6025e77 --- /dev/null +++ b/docs/examples/mysql/update-pooler.md @@ -0,0 +1,30 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.update_pooler( + "", + Some("transaction"), // optional + Some(10), // optional + Some(1), // optional + Some(false), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md new file mode 100644 index 0000000..e2f1d1e --- /dev/null +++ b/docs/examples/mysql/update.md @@ -0,0 +1,42 @@ +```rust +use appwrite::Client; +use appwrite::services::Mysql; + +#[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 mysql = Mysql::new(&client); + + let result = mysql.update( + "", + Some(""), // optional + Some("ready"), // optional + Some(""), // optional + Some(0), // optional + Some("async"), // optional + Some(60), // optional + Some(vec![]), // optional + Some(5), // optional + Some(false), // optional + Some(1), // optional + Some(false), // optional + Some(50), // optional + Some(0), // optional + Some(0), // optional + Some(0), // optional + Some(false), // optional + Some(vec![]), // optional + Some(1), // optional + Some(1024), // optional + Some(1) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/organization/create-project.md b/docs/examples/organization/create-project.md index 2cc7f3b..a28464c 100644 --- a/docs/examples/organization/create-project.md +++ b/docs/examples/organization/create-project.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let organization = Organization::new(&client); let result = organization.create_project( - "", + "", "", Some(appwrite::enums::Region::Fra) // optional ).await?; diff --git a/docs/examples/postgresql/create-backup-policy.md b/docs/examples/postgresql/create-backup-policy.md new file mode 100644 index 0000000..db61e5b --- /dev/null +++ b/docs/examples/postgresql/create-backup-policy.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_backup_policy( + "", + "", + "", + "", + 1, + Some("full"), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-backup.md b/docs/examples/postgresql/create-backup.md new file mode 100644 index 0000000..d4b1ee2 --- /dev/null +++ b/docs/examples/postgresql/create-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_backup( + "", + Some("full") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-branch.md b/docs/examples/postgresql/create-branch.md new file mode 100644 index 0000000..fc78e24 --- /dev/null +++ b/docs/examples/postgresql/create-branch.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_branch( + "", + Some(""), // optional + Some(300) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-execution.md b/docs/examples/postgresql/create-execution.md new file mode 100644 index 0000000..3c5bf09 --- /dev/null +++ b/docs/examples/postgresql/create-execution.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_execution( + "", + "", + Some(serde_json::json!({})), // optional + Some(1) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-extension.md b/docs/examples/postgresql/create-extension.md new file mode 100644 index 0000000..b7a9cd7 --- /dev/null +++ b/docs/examples/postgresql/create-extension.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_extension( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-failover.md b/docs/examples/postgresql/create-failover.md new file mode 100644 index 0000000..758cac3 --- /dev/null +++ b/docs/examples/postgresql/create-failover.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_failover( + "", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-migration.md b/docs/examples/postgresql/create-migration.md new file mode 100644 index 0000000..5c0b515 --- /dev/null +++ b/docs/examples/postgresql/create-migration.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_migration( + "", + "shared", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md new file mode 100644 index 0000000..bac2e85 --- /dev/null +++ b/docs/examples/postgresql/create-restoration.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_restoration( + "", + Some("backup"), // optional + Some(""), // optional + Some(""), // optional + Some("2020-10-15T06:38:00.000+00:00") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create-upgrade.md b/docs/examples/postgresql/create-upgrade.md new file mode 100644 index 0000000..e1866b8 --- /dev/null +++ b/docs/examples/postgresql/create-upgrade.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create_upgrade( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/create.md b/docs/examples/postgresql/create.md new file mode 100644 index 0000000..10e5409 --- /dev/null +++ b/docs/examples/postgresql/create.md @@ -0,0 +1,35 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.create( + "", + "", + Some("17"), // optional + Some(""), // optional + Some(0), // optional + Some("async"), // optional + Some(60), // optional + Some(vec![]), // optional + Some(5), // optional + Some(false), // optional + Some(1), // optional + Some(false), // optional + Some(50), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md new file mode 100644 index 0000000..1362635 --- /dev/null +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.delete_backup_policy( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md new file mode 100644 index 0000000..f30ba45 --- /dev/null +++ b/docs/examples/postgresql/delete-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.delete_backup( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/delete-branch.md b/docs/examples/postgresql/delete-branch.md new file mode 100644 index 0000000..d3edb28 --- /dev/null +++ b/docs/examples/postgresql/delete-branch.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.delete_branch( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/delete-extension.md b/docs/examples/postgresql/delete-extension.md new file mode 100644 index 0000000..8678e6d --- /dev/null +++ b/docs/examples/postgresql/delete-extension.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.delete_extension( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md new file mode 100644 index 0000000..4d9207e --- /dev/null +++ b/docs/examples/postgresql/delete.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.delete( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-backup-policy.md b/docs/examples/postgresql/get-backup-policy.md new file mode 100644 index 0000000..49e7ef5 --- /dev/null +++ b/docs/examples/postgresql/get-backup-policy.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_backup_policy( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-backup.md b/docs/examples/postgresql/get-backup.md new file mode 100644 index 0000000..18c8423 --- /dev/null +++ b/docs/examples/postgresql/get-backup.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_backup( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-pitr.md b/docs/examples/postgresql/get-pitr.md new file mode 100644 index 0000000..c5b02e1 --- /dev/null +++ b/docs/examples/postgresql/get-pitr.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_pitr( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-pooler.md b/docs/examples/postgresql/get-pooler.md new file mode 100644 index 0000000..107c470 --- /dev/null +++ b/docs/examples/postgresql/get-pooler.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_pooler( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-replicas.md b/docs/examples/postgresql/get-replicas.md new file mode 100644 index 0000000..64e56d5 --- /dev/null +++ b/docs/examples/postgresql/get-replicas.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_replicas( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-restoration.md b/docs/examples/postgresql/get-restoration.md new file mode 100644 index 0000000..b7a9a24 --- /dev/null +++ b/docs/examples/postgresql/get-restoration.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_restoration( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get-status.md b/docs/examples/postgresql/get-status.md new file mode 100644 index 0000000..36ac2c0 --- /dev/null +++ b/docs/examples/postgresql/get-status.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get_status( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/get.md b/docs/examples/postgresql/get.md new file mode 100644 index 0000000..dd1a4fc --- /dev/null +++ b/docs/examples/postgresql/get.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.get( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-backup-policies.md b/docs/examples/postgresql/list-backup-policies.md new file mode 100644 index 0000000..af79896 --- /dev/null +++ b/docs/examples/postgresql/list-backup-policies.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_backup_policies( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-backups.md b/docs/examples/postgresql/list-backups.md new file mode 100644 index 0000000..d0f6d6b --- /dev/null +++ b/docs/examples/postgresql/list-backups.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_backups( + "", + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-branches.md b/docs/examples/postgresql/list-branches.md new file mode 100644 index 0000000..58e705f --- /dev/null +++ b/docs/examples/postgresql/list-branches.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_branches( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-extensions.md b/docs/examples/postgresql/list-extensions.md new file mode 100644 index 0000000..015f676 --- /dev/null +++ b/docs/examples/postgresql/list-extensions.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_extensions( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-operations.md b/docs/examples/postgresql/list-operations.md new file mode 100644 index 0000000..aaec1a7 --- /dev/null +++ b/docs/examples/postgresql/list-operations.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_operations( + "", + Some("queued"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-restorations.md b/docs/examples/postgresql/list-restorations.md new file mode 100644 index 0000000..68971de --- /dev/null +++ b/docs/examples/postgresql/list-restorations.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_restorations( + "", + Some("pending"), // optional + Some("backup"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list-specifications.md b/docs/examples/postgresql/list-specifications.md new file mode 100644 index 0000000..88d9b73 --- /dev/null +++ b/docs/examples/postgresql/list-specifications.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list_specifications().await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/list.md b/docs/examples/postgresql/list.md new file mode 100644 index 0000000..9aee99d --- /dev/null +++ b/docs/examples/postgresql/list.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.list( + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/update-backup-policy.md b/docs/examples/postgresql/update-backup-policy.md new file mode 100644 index 0000000..e59509c --- /dev/null +++ b/docs/examples/postgresql/update-backup-policy.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.update_backup_policy( + "", + "", + Some(""), // optional + Some(""), // optional + Some(1), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/update-backup-storage.md b/docs/examples/postgresql/update-backup-storage.md new file mode 100644 index 0000000..a7c8cb3 --- /dev/null +++ b/docs/examples/postgresql/update-backup-storage.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.update_backup_storage( + "", + "s3", + "", + "", + "", + Some(""), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/update-credentials.md b/docs/examples/postgresql/update-credentials.md new file mode 100644 index 0000000..7af609f --- /dev/null +++ b/docs/examples/postgresql/update-credentials.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.update_credentials( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/update-maintenance.md b/docs/examples/postgresql/update-maintenance.md new file mode 100644 index 0000000..e07cdbf --- /dev/null +++ b/docs/examples/postgresql/update-maintenance.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.update_maintenance( + "", + "sun", + 0 + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/update-pooler.md b/docs/examples/postgresql/update-pooler.md new file mode 100644 index 0000000..fffe5aa --- /dev/null +++ b/docs/examples/postgresql/update-pooler.md @@ -0,0 +1,30 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.update_pooler( + "", + Some("transaction"), // optional + Some(10), // optional + Some(1), // optional + Some(false), // optional + Some(""), // optional + Some(""), // optional + Some(""), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md new file mode 100644 index 0000000..79d854a --- /dev/null +++ b/docs/examples/postgresql/update.md @@ -0,0 +1,42 @@ +```rust +use appwrite::Client; +use appwrite::services::Postgresql; + +#[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 postgresql = Postgresql::new(&client); + + let result = postgresql.update( + "", + Some(""), // optional + Some("ready"), // optional + Some(""), // optional + Some(0), // optional + Some("async"), // optional + Some(60), // optional + Some(vec![]), // optional + Some(5), // optional + Some(false), // optional + Some(1), // optional + Some(false), // optional + Some(50), // optional + Some(0), // optional + Some(0), // optional + Some(0), // optional + Some(false), // optional + Some(vec![]), // optional + Some(1), // optional + Some(1024), // optional + Some(1) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-o-auth-2-hugging-face.md b/docs/examples/project/update-o-auth-2-hugging-face.md new file mode 100644 index 0000000..275e2d9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-hugging-face.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_hugging_face( + Some(""), // optional + Some(""), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index b180d2b..5273104 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = project.update_o_auth2_okta( Some(""), // optional Some(""), // optional - Some(""), // optional + Some("example.com"), // optional Some(""), // optional Some(false) // optional ).await?; diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md index 6080824..d4fa577 100644 --- a/docs/examples/project/update-smtp.md +++ b/docs/examples/project/update-smtp.md @@ -12,8 +12,8 @@ async fn main() -> Result<(), Box> { let project = Project::new(&client); let result = project.update_smtp( - Some(""), // optional - Some(0), // optional + Some("example.com"), // optional + Some(587), // optional Some(""), // optional Some("password"), // optional Some("email@example.com"), // optional diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md index 740146a..50d0321 100644 --- a/docs/examples/proxy/create-api-rule.md +++ b/docs/examples/proxy/create-api-rule.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let proxy = Proxy::new(&client); let result = proxy.create_api_rule( - "" + "example.com" ).await?; let _ = result; diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md index 0200f9d..c2ef9ce 100644 --- a/docs/examples/proxy/create-function-rule.md +++ b/docs/examples/proxy/create-function-rule.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let proxy = Proxy::new(&client); let result = proxy.create_function_rule( - "", + "example.com", "", Some("") // optional ).await?; diff --git a/docs/examples/proxy/create-invalidation.md b/docs/examples/proxy/create-invalidation.md index 66b3687..ba4b1aa 100644 --- a/docs/examples/proxy/create-invalidation.md +++ b/docs/examples/proxy/create-invalidation.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let proxy = Proxy::new(&client); let result = proxy.create_invalidation( - "", + "example.com", appwrite::enums::InvalidationType::Tag, Some("") // optional ).await?; diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md index 803ffba..bb5a8a7 100644 --- a/docs/examples/proxy/create-redirect-rule.md +++ b/docs/examples/proxy/create-redirect-rule.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let proxy = Proxy::new(&client); let result = proxy.create_redirect_rule( - "", + "example.com", "https://example.com", appwrite::enums::StatusCode::MovedPermanently, "", diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md index 457ff6c..7c14838 100644 --- a/docs/examples/proxy/create-site-rule.md +++ b/docs/examples/proxy/create-site-rule.md @@ -12,7 +12,7 @@ async fn main() -> Result<(), Box> { let proxy = Proxy::new(&client); let result = proxy.create_site_rule( - "", + "example.com", "", Some("") // optional ).await?; diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index 051514f..5f4c334 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -32,9 +32,10 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(vec![]), // optional Some(vec![]), // optional - Some(""), // optional - Some(""), // optional - Some(0) // optional + Some("s-1vcpu-512mb"), // optional + Some("s-1vcpu-512mb"), // optional + Some(0), // optional + Some(vec![appwrite::enums::ProjectKeyScopes::ProjectRead]) // optional ).await?; let _ = result; diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index 90a5cf2..24eaea1 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -32,9 +32,10 @@ async fn main() -> Result<(), Box> { Some(""), // optional Some(vec![]), // optional Some(vec![]), // optional - Some(""), // optional - Some(""), // optional - Some(0) // optional + Some("s-1vcpu-512mb"), // optional + Some("s-1vcpu-512mb"), // optional + Some(0), // optional + Some(vec![appwrite::enums::ProjectKeyScopes::ProjectRead]) // optional ).await?; let _ = result; diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index e470922..882803c 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -21,7 +21,7 @@ async fn main() -> Result<(), Box> { "", file, Some(vec![Permission::read(Role::any()).to_string()]), // optional - Some("") // optional + Some("photos/2026") // optional ).await?; let _ = result; diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 004702c..f8f2406 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -19,11 +19,11 @@ async fn main() -> Result<(), Box> { Some(appwrite::enums::ImageGravity::Center), // optional Some(-1), // optional Some(0), // optional - Some(""), // optional + Some("FFFFFF"), // optional Some(0), // optional Some(0), // optional Some(-360), // optional - Some(""), // optional + Some("FFFFFF"), // optional Some(appwrite::enums::ImageFormat::Jpg), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md index 897ed1d..03b0ab6 100644 --- a/docs/examples/tablesdb/create-big-int-column.md +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_big_int_column( "", "", - "", + "", false, Some(0), // optional - Some(0), // optional + Some(1000000), // optional Some(0), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md index e05f581..1762d5e 100644 --- a/docs/examples/tablesdb/create-boolean-column.md +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_boolean_column( "", "", - "", + "", false, Some(false), // optional Some(false) // optional diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index b9ddd4f..31c8d7c 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_datetime_column( "", "", - "", + "", false, Some("2020-10-15T06:38:00.000+00:00"), // optional Some(false) // optional diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md index 19d0bc0..11f800c 100644 --- a/docs/examples/tablesdb/create-email-column.md +++ b/docs/examples/tablesdb/create-email-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_email_column( "", "", - "", + "", false, Some("email@example.com"), // optional Some(false) // optional diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index fe9c610..64d1496 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_enum_column( "", "", - "", - vec![], + "", + vec!["active".into(), "inactive".into()], false, - Some(""), // optional + Some("active"), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md index ca7735e..9c3179a 100644 --- a/docs/examples/tablesdb/create-float-column.md +++ b/docs/examples/tablesdb/create-float-column.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_float_column( "", "", - "", + "", false, Some(0), // optional - Some(0), // optional - Some(0), // optional + Some(100), // optional + Some(10.5), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 2807f30..409d88d 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_index( "", "", - "", + "", appwrite::enums::TablesDBIndexType::Key, vec![], Some(vec![appwrite::enums::OrderBy::Asc]), // optional diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md index 83df6e5..7565228 100644 --- a/docs/examples/tablesdb/create-integer-column.md +++ b/docs/examples/tablesdb/create-integer-column.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_integer_column( "", "", - "", + "", false, Some(0), // optional - Some(0), // optional - Some(0), // optional + Some(100), // optional + Some(10), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md index e6de2c1..c59cd2e 100644 --- a/docs/examples/tablesdb/create-ip-column.md +++ b/docs/examples/tablesdb/create-ip-column.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_ip_column( "", "", - "", + "", false, - Some(""), // optional + Some("192.0.2.0"), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index e9f03af..70812a4 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_line_column( "", "", - "", + "", false, Some(vec![serde_json::json!([1,2]), serde_json::json!([3,4]), serde_json::json!([5,6])]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md index fd07339..85a2b4b 100644 --- a/docs/examples/tablesdb/create-longtext-column.md +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_longtext_column( "", "", - "", + "", false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md index adc8a26..35d022d 100644 --- a/docs/examples/tablesdb/create-mediumtext-column.md +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_mediumtext_column( "", "", - "", + "", false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 2a72e0c..750f777 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_point_column( "", "", - "", + "", false, Some(vec![1, 2]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 18cbe48..b9a598f 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_polygon_column( "", "", - "", + "", false, Some(vec![serde_json::json!([[1,2],[3,4],[5,6],[1,2]])]) // optional ).await?; diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md index fb288e8..12e8d26 100644 --- a/docs/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -17,8 +17,8 @@ async fn main() -> Result<(), Box> { "", appwrite::enums::RelationshipType::OneToOne, Some(false), // optional - Some(""), // optional - Some(""), // optional + Some(""), // optional + Some(""), // optional Some(appwrite::enums::RelationMutate::Cascade) // optional ).await?; diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md index 17f2515..2e6118a 100644 --- a/docs/examples/tablesdb/create-string-column.md +++ b/docs/examples/tablesdb/create-string-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_string_column( "", "", - "", + "", 1, false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md index 492d1f6..c8cb8cc 100644 --- a/docs/examples/tablesdb/create-text-column.md +++ b/docs/examples/tablesdb/create-text-column.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_text_column( "", "", - "", + "", false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md index 000fd91..aed6a84 100644 --- a/docs/examples/tablesdb/create-url-column.md +++ b/docs/examples/tablesdb/create-url-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_url_column( "", "", - "", + "", false, Some("https://example.com"), // optional Some(false) // optional diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md index 4ee2404..8be2741 100644 --- a/docs/examples/tablesdb/create-varchar-column.md +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.create_varchar_column( "", "", - "", + "", 1, false, - Some(""), // optional + Some("Hello World"), // optional Some(false), // optional Some(false) // optional ).await?; diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 5cb4b94..f0fc521 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -15,8 +15,8 @@ async fn main() -> Result<(), Box> { "", "", "", - "", - Some(0), // optional + "", + Some(1), // optional Some(0), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md index b16779b..3b4d2e1 100644 --- a/docs/examples/tablesdb/delete-column.md +++ b/docs/examples/tablesdb/delete-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { tables_db.delete_column( "", "", - "" + "" ).await?; Ok(()) diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md index 43da9eb..50d7371 100644 --- a/docs/examples/tablesdb/delete-index.md +++ b/docs/examples/tablesdb/delete-index.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { tables_db.delete_index( "", "", - "" + "" ).await?; Ok(()) diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 2d3c3ee..d7b1bd0 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.get_column( "", "", - "" + "" ).await?; let _ = result; diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md index 7319aa2..cc9c124 100644 --- a/docs/examples/tablesdb/get-index.md +++ b/docs/examples/tablesdb/get-index.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.get_index( "", "", - "" + "" ).await?; let _ = result; diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index be4f0d3..d618d08 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -15,9 +15,9 @@ async fn main() -> Result<(), Box> { "", "", "", - "", - Some(0), // optional - Some(0), // optional + "", + Some(1), // optional + Some(100), // optional Some("") // optional ).await?; diff --git a/docs/examples/tablesdb/list-operations.md b/docs/examples/tablesdb/list-operations.md index 3454f24..f1458c3 100644 --- a/docs/examples/tablesdb/list-operations.md +++ b/docs/examples/tablesdb/list-operations.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = tables_db.list_operations( "", - Some("running"), // optional + Some("queued"), // optional Some(1), // optional Some(0) // optional ).await?; diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md index b6b9f18..1f0eabd 100644 --- a/docs/examples/tablesdb/update-big-int-column.md +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -14,12 +14,12 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_big_int_column( "", "", - "", + "", false, Some(0), Some(0), // optional - Some(0), // optional - Some("") // optional + Some(1000000), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md index a7a871a..3a65cab 100644 --- a/docs/examples/tablesdb/update-boolean-column.md +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_boolean_column( "", "", - "", + "", false, Some(false), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index 6200842..612a1cb 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_datetime_column( "", "", - "", + "", false, Some("2020-10-15T06:38:00.000+00:00"), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md index e19b352..c6f29c7 100644 --- a/docs/examples/tablesdb/update-email-column.md +++ b/docs/examples/tablesdb/update-email-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_email_column( "", "", - "", + "", false, Some("email@example.com"), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index d0de7b0..7806f9c 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_enum_column( "", "", - "", - vec![], + "", + vec!["active".into(), "inactive".into()], false, - Some(""), - Some("") // optional + Some("active"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md index 77ee532..25b5ad2 100644 --- a/docs/examples/tablesdb/update-float-column.md +++ b/docs/examples/tablesdb/update-float-column.md @@ -14,12 +14,12 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_float_column( "", "", - "", + "", false, - Some(0), + Some(10.5), Some(0), // optional - Some(0), // optional - Some("") // optional + Some(100), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md index a290193..7053a0d 100644 --- a/docs/examples/tablesdb/update-integer-column.md +++ b/docs/examples/tablesdb/update-integer-column.md @@ -14,12 +14,12 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_integer_column( "", "", - "", + "", false, - Some(0), + Some(10), Some(0), // optional - Some(0), // optional - Some("") // optional + Some(100), // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md index d20dc47..261a8ce 100644 --- a/docs/examples/tablesdb/update-ip-column.md +++ b/docs/examples/tablesdb/update-ip-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_ip_column( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("192.0.2.0"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index 60aa70a..a87f098 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_line_column( "", "", - "", + "", false, Some(vec![serde_json::json!([1,2]), serde_json::json!([3,4]), serde_json::json!([5,6])]), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md index e7867b1..a5629b3 100644 --- a/docs/examples/tablesdb/update-longtext-column.md +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_longtext_column( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("Hello World"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md index df7813f..4a8162d 100644 --- a/docs/examples/tablesdb/update-mediumtext-column.md +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_mediumtext_column( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("Hello World"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index 35264ba..33f4d27 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_point_column( "", "", - "", + "", false, Some(vec![1, 2]), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 01da757..c3504e6 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_polygon_column( "", "", - "", + "", false, Some(vec![serde_json::json!([[1,2],[3,4],[5,6],[1,2]])]), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md index a242ceb..8c83d0d 100644 --- a/docs/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_relationship_column( "", "", - "", + "", Some(appwrite::enums::RelationMutate::Cascade), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md index 0bdf03a..ea6dde7 100644 --- a/docs/examples/tablesdb/update-string-column.md +++ b/docs/examples/tablesdb/update-string-column.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_string_column( "", "", - "", + "", false, - Some(""), + Some("Hello World"), Some(1), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md index 8b29968..f9376ca 100644 --- a/docs/examples/tablesdb/update-text-column.md +++ b/docs/examples/tablesdb/update-text-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_text_column( "", "", - "", + "", false, - Some(""), - Some("") // optional + Some("Hello World"), + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md index 853a5ec..57afcdc 100644 --- a/docs/examples/tablesdb/update-url-column.md +++ b/docs/examples/tablesdb/update-url-column.md @@ -14,10 +14,10 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_url_column( "", "", - "", + "", false, Some("https://example.com"), - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md index ff3a27f..02d74b3 100644 --- a/docs/examples/tablesdb/update-varchar-column.md +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -14,11 +14,11 @@ async fn main() -> Result<(), Box> { let result = tables_db.update_varchar_column( "", "", - "", + "", false, - Some(""), + Some("Hello World"), Some(1), // optional - Some("") // optional + Some("") // optional ).await?; let _ = result; diff --git a/docs/examples/users/create-jwt.md b/docs/examples/users/create-jwt.md index 2e5949b..d728829 100644 --- a/docs/examples/users/create-jwt.md +++ b/docs/examples/users/create-jwt.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = users.create_jwt( "", - Some(""), // optional + Some("recent()"), // optional Some(0) // optional ).await?; diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index ec652df..f87ef4a 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -16,10 +16,10 @@ async fn main() -> Result<(), Box> { "email@example.com", "password", "", - 0, - 0, - 0, - 0, + 8, + 65536, + 1, + 64, Some("") // optional ).await?; diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md new file mode 100644 index 0000000..1010288 --- /dev/null +++ b/docs/examples/vectorsdb/create-collection.md @@ -0,0 +1,30 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_collection( + "", + "", + "", + 1, + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some(false), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md new file mode 100644 index 0000000..fcbfa5c --- /dev/null +++ b/docs/examples/vectorsdb/create-document.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_document( + "", + "", + "", + serde_json::json!({}), + Some(vec![Permission::read(Role::any()).to_string()]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md new file mode 100644 index 0000000..bf49c41 --- /dev/null +++ b/docs/examples/vectorsdb/create-documents.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_documents( + "", + "", + vec![] + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-failover.md b/docs/examples/vectorsdb/create-failover.md new file mode 100644 index 0000000..5af7a6b --- /dev/null +++ b/docs/examples/vectorsdb/create-failover.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_failover( + "", + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md new file mode 100644 index 0000000..02d30e2 --- /dev/null +++ b/docs/examples/vectorsdb/create-index.md @@ -0,0 +1,28 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_index( + "", + "", + "", + appwrite::enums::VectorsDBIndexType::HnswEuclidean, + vec![], + Some(vec![appwrite::enums::OrderBy::Asc]), // optional + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md new file mode 100644 index 0000000..cc1aaca --- /dev/null +++ b/docs/examples/vectorsdb/create-operations.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_operations( + "", + Some(vec![serde_json::json!({"action":"create","databaseId":"","collectionId":"","documentId":"","data":{"name":"Walter O'Brien"}})]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-query.md b/docs/examples/vectorsdb/create-query.md new file mode 100644 index 0000000..72ea46b --- /dev/null +++ b/docs/examples/vectorsdb/create-query.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_query( + "", + "", + Some(vec![]), // optional + Some(""), // optional + Some(false), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md new file mode 100644 index 0000000..a7b1919 --- /dev/null +++ b/docs/examples/vectorsdb/create-transaction.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create_transaction( + Some(60) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md new file mode 100644 index 0000000..bfcf81f --- /dev/null +++ b/docs/examples/vectorsdb/create.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.create( + "", + "", + Some(false), // optional + Some("serverless"), // optional + Some(0), // optional + Some("async") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md new file mode 100644 index 0000000..4a500dc --- /dev/null +++ b/docs/examples/vectorsdb/delete-collection.md @@ -0,0 +1,21 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + vectors_db.delete_collection( + "", + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md new file mode 100644 index 0000000..0899b84 --- /dev/null +++ b/docs/examples/vectorsdb/delete-document.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + vectors_db.delete_document( + "", + "", + "", + Some("") // optional + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md new file mode 100644 index 0000000..a69a6a7 --- /dev/null +++ b/docs/examples/vectorsdb/delete-documents.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.delete_documents( + "", + "", + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md new file mode 100644 index 0000000..865864f --- /dev/null +++ b/docs/examples/vectorsdb/delete-index.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + vectors_db.delete_index( + "", + "", + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md new file mode 100644 index 0000000..1e2be2b --- /dev/null +++ b/docs/examples/vectorsdb/delete-transaction.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + vectors_db.delete_transaction( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md new file mode 100644 index 0000000..daea462 --- /dev/null +++ b/docs/examples/vectorsdb/delete.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + vectors_db.delete( + "" + ).await?; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md new file mode 100644 index 0000000..2aa56e7 --- /dev/null +++ b/docs/examples/vectorsdb/get-collection.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get_collection( + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md new file mode 100644 index 0000000..3823531 --- /dev/null +++ b/docs/examples/vectorsdb/get-document.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get_document( + "", + "", + "", + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md new file mode 100644 index 0000000..e707c68 --- /dev/null +++ b/docs/examples/vectorsdb/get-index.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get_index( + "", + "", + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get-replicas.md b/docs/examples/vectorsdb/get-replicas.md new file mode 100644 index 0000000..fa3c4c1 --- /dev/null +++ b/docs/examples/vectorsdb/get-replicas.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get_replicas( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get-status.md b/docs/examples/vectorsdb/get-status.md new file mode 100644 index 0000000..a390b9a --- /dev/null +++ b/docs/examples/vectorsdb/get-status.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get_status( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md new file mode 100644 index 0000000..d3ddeae --- /dev/null +++ b/docs/examples/vectorsdb/get-transaction.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get_transaction( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md new file mode 100644 index 0000000..4009249 --- /dev/null +++ b/docs/examples/vectorsdb/get.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.get( + "" + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md new file mode 100644 index 0000000..900820c --- /dev/null +++ b/docs/examples/vectorsdb/list-collections.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list_collections( + "", + Some(vec![]), // optional + Some(""), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md new file mode 100644 index 0000000..bea7001 --- /dev/null +++ b/docs/examples/vectorsdb/list-documents.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list_documents( + "", + "", + Some(vec![]), // optional + Some(""), // optional + Some(false), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md new file mode 100644 index 0000000..0a28c93 --- /dev/null +++ b/docs/examples/vectorsdb/list-indexes.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list_indexes( + "", + "", + Some(vec![]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list-operations.md b/docs/examples/vectorsdb/list-operations.md new file mode 100644 index 0000000..6a4fa78 --- /dev/null +++ b/docs/examples/vectorsdb/list-operations.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list_operations( + "", + Some("queued"), // optional + Some(1), // optional + Some(0) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list-specifications.md b/docs/examples/vectorsdb/list-specifications.md new file mode 100644 index 0000000..40a4e29 --- /dev/null +++ b/docs/examples/vectorsdb/list-specifications.md @@ -0,0 +1,20 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list_specifications().await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md new file mode 100644 index 0000000..214670d --- /dev/null +++ b/docs/examples/vectorsdb/list-transactions.md @@ -0,0 +1,22 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list_transactions( + Some(vec![]) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md new file mode 100644 index 0000000..7920c3c --- /dev/null +++ b/docs/examples/vectorsdb/list.md @@ -0,0 +1,23 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.list( + Some(vec![]), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md new file mode 100644 index 0000000..86309ba --- /dev/null +++ b/docs/examples/vectorsdb/update-collection.md @@ -0,0 +1,30 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.update_collection( + "", + "", + "", + Some(1), // optional + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some(false), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md new file mode 100644 index 0000000..738c3c0 --- /dev/null +++ b/docs/examples/vectorsdb/update-document.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.update_document( + "", + "", + "", + Some(serde_json::json!({})), // optional + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md new file mode 100644 index 0000000..d616e73 --- /dev/null +++ b/docs/examples/vectorsdb/update-documents.md @@ -0,0 +1,26 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.update_documents( + "", + "", + Some(serde_json::json!({})), // optional + Some(vec![]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md new file mode 100644 index 0000000..75f9534 --- /dev/null +++ b/docs/examples/vectorsdb/update-transaction.md @@ -0,0 +1,24 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.update_transaction( + "", + Some(false), // optional + Some(false) // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md new file mode 100644 index 0000000..d1a4703 --- /dev/null +++ b/docs/examples/vectorsdb/update.md @@ -0,0 +1,27 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.update( + "", + "", + Some(false), // optional + Some("serverless"), // optional + Some(0), // optional + Some("async") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md new file mode 100644 index 0000000..3bc89cc --- /dev/null +++ b/docs/examples/vectorsdb/upsert-document.md @@ -0,0 +1,29 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; +use appwrite::permission::Permission; +use appwrite::role::Role; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.upsert_document( + "", + "", + "", + Some(serde_json::json!({})), // optional + Some(vec![Permission::read(Role::any()).to_string()]), // optional + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md new file mode 100644 index 0000000..c556118 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -0,0 +1,25 @@ +```rust +use appwrite::Client; +use appwrite::services::VectorsDB; + +#[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 vectors_db = VectorsDB::new(&client); + + let result = vectors_db.upsert_documents( + "", + "", + vec![], + Some("") // optional + ).await?; + + let _ = result; + + Ok(()) +} +``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 8bffd65..a14a6c1 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box> { let result = webhooks.create( "", - "", + "https://example.com/webhook", "", vec![], Some(false), // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 6873084..73d636d 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -14,7 +14,7 @@ async fn main() -> Result<(), Box> { let result = webhooks.update( "", "", - "", + "https://example.com/webhook", vec![], Some(false), // optional Some(false), // optional diff --git a/src/client.rs b/src/client.rs index 270d29d..ded649b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -92,11 +92,20 @@ impl Client { pub fn new() -> Self { let mut headers = HeaderMap::new(); headers.insert("X-Appwrite-Response-Format", "1.9.6".parse().unwrap()); - headers.insert("user-agent", format!("AppwriteRustSDK/0.13.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH).parse().unwrap()); + headers.insert( + "user-agent", + format!( + "AppwriteRustSDK/0.14.0-rc.1 ({}; {})", + std::env::consts::OS, + std::env::consts::ARCH + ) + .parse() + .unwrap(), + ); 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.13.0".parse().unwrap()); + headers.insert("x-sdk-version", "0.14.0-rc.1".parse().unwrap()); let config = Config { endpoint: "https://cloud.appwrite.io/v1".to_string(), @@ -109,7 +118,11 @@ impl Client { let http = Self::build_http_client(&config); let http_no_redirect = Self::build_http_client_no_redirect(&config); - let state = ClientState { config, http, http_no_redirect }; + let state = ClientState { + config, + http, + http_no_redirect, + }; Self { state: Arc::new(ArcSwap::from_pointee(state)), @@ -135,14 +148,19 @@ impl Client { builder = builder.danger_accept_invalid_certs(true); } - builder.build().expect("Failed to create no-redirect HTTP client") + builder + .build() + .expect("Failed to create no-redirect HTTP client") } /// Set the API endpoint pub fn set_endpoint>(&self, endpoint: S) -> Self { let endpoint = endpoint.into(); if !endpoint.starts_with("http://") && !endpoint.starts_with("https://") { - panic!("Invalid endpoint URL: {}. Endpoint must start with http:// or https://", endpoint); + panic!( + "Invalid endpoint URL: {}. Endpoint must start with http:// or https://", + endpoint + ); } self.state.rcu(|state| { let mut next = (**state).clone(); @@ -152,7 +170,6 @@ impl Client { self.clone() } - /// Set Project /// /// Your project ID @@ -160,7 +177,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-project", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-project", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -173,7 +192,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-key", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-key", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -186,7 +207,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-organization", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-organization", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -199,7 +222,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-jwt", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-jwt", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -212,7 +237,10 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("authorization", format!("Bearer {}", value).parse().unwrap()); + next.config.headers.insert( + "authorization", + format!("Bearer {}", value).parse().unwrap(), + ); Arc::new(next) }); self.clone() @@ -223,7 +251,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-locale", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-locale", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -236,7 +266,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-session", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-session", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -249,7 +281,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-forwarded-user-agent", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-forwarded-user-agent", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -262,7 +296,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-dev-key", value.clone().parse().unwrap()); + next.config + .headers + .insert("x-appwrite-dev-key", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -275,7 +311,9 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("cookie", value.clone().parse().unwrap()); + next.config + .headers + .insert("cookie", value.clone().parse().unwrap()); Arc::new(next) }); self.clone() @@ -288,7 +326,10 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-impersonate-user-id", value.clone().parse().unwrap()); + next.config.headers.insert( + "x-appwrite-impersonate-user-id", + value.clone().parse().unwrap(), + ); Arc::new(next) }); self.clone() @@ -301,7 +342,10 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-impersonate-user-email", value.clone().parse().unwrap()); + next.config.headers.insert( + "x-appwrite-impersonate-user-email", + value.clone().parse().unwrap(), + ); Arc::new(next) }); self.clone() @@ -314,7 +358,10 @@ impl Client { let value = value.into(); self.state.rcu(|state| { let mut next = (**state).clone(); - next.config.headers.insert("x-appwrite-impersonate-user-phone", value.clone().parse().unwrap()); + next.config.headers.insert( + "x-appwrite-impersonate-user-phone", + value.clone().parse().unwrap(), + ); Arc::new(next) }); self.clone() @@ -367,10 +414,9 @@ impl Client { self.state.rcu(|state| { let mut next = (**state).clone(); - if let (Ok(header_name), Ok(header_value)) = ( - key.parse::(), - value.parse::(), - ) { + if let (Ok(header_name), Ok(header_value)) = + (key.parse::(), value.parse::()) + { next.config.headers.insert(header_name, header_value); } Arc::new(next) @@ -432,13 +478,19 @@ impl Client { Value::Bool(b) => result.push((format!("{}[]", key), b.to_string())), Value::Null => result.push((format!("{}[]", key), String::new())), _ => { - result.push((format!("{}[]", key), serde_json::to_string(item).unwrap_or_default())); + result.push(( + format!("{}[]", key), + serde_json::to_string(item).unwrap_or_default(), + )); } } } } Value::Object(_) => { - result.push((key.clone(), serde_json::to_string(value).unwrap_or_default())); + result.push(( + key.clone(), + serde_json::to_string(value).unwrap_or_default(), + )); } _ => { result.push((key.clone(), Self::serialize_param_value(value))); @@ -451,7 +503,10 @@ impl Client { /// Flatten nested parameters for multipart form data /// Converts nested arrays/objects to bracket notation: key[0], key[subkey], etc. - fn flatten_multipart_params(params: &HashMap, prefix: &str) -> Vec<(String, String)> { + fn flatten_multipart_params( + params: &HashMap, + prefix: &str, + ) -> Vec<(String, String)> { let mut result = Vec::new(); for (key, value) in params { @@ -505,7 +560,9 @@ impl Client { if let Some(params) = params { if method == Method::GET { - let mut url_with_params = Url::parse(&url).map_err(|e| AppwriteError::new(0, format!("Invalid URL: {}", e), None, String::new()))?; + let mut url_with_params = Url::parse(&url).map_err(|e| { + AppwriteError::new(0, format!("Invalid URL: {}", e), None, String::new()) + })?; { let mut query_pairs = url_with_params.query_pairs_mut(); for (key, value) in Self::flatten_query_params(¶ms) { @@ -556,7 +613,9 @@ impl Client { if let Some(params) = params { if method == Method::GET { - let mut url_with_params = Url::parse(&url).map_err(|e| AppwriteError::new(0, format!("Invalid URL: {}", e), None, String::new()))?; + let mut url_with_params = Url::parse(&url).map_err(|e| { + AppwriteError::new(0, format!("Invalid URL: {}", e), None, String::new()) + })?; { let mut query_pairs = url_with_params.query_pairs_mut(); for (key, value) in Self::flatten_query_params(¶ms) { @@ -585,12 +644,14 @@ impl Client { .get("location") .and_then(|v| v.to_str().ok()) .map(|s| s.to_string()) - .ok_or_else(|| AppwriteError::new( - status.as_u16(), - "Location header not found in redirect response", - None, - String::new(), - )) + .ok_or_else(|| { + AppwriteError::new( + status.as_u16(), + "Location header not found in redirect response", + None, + String::new(), + ) + }) } else { let content_type = response .headers() @@ -643,7 +704,9 @@ impl Client { if let Some(params) = params { if method == Method::GET { - let mut url_with_params = Url::parse(&url).map_err(|e| AppwriteError::new(0, format!("Invalid URL: {}", e), None, String::new()))?; + let mut url_with_params = Url::parse(&url).map_err(|e| { + AppwriteError::new(0, format!("Invalid URL: {}", e), None, String::new()) + })?; { let mut query_pairs = url_with_params.query_pairs_mut(); for (key, value) in Self::flatten_query_params(¶ms) { @@ -759,7 +822,9 @@ impl Client { let state = self.state.load_full(); let url = format!("{}{}", state.config.endpoint, path); - let result = self.single_file_upload(&url, headers, params, param_name, &input_file).await?; + let result = self + .single_file_upload(&url, headers, params, param_name, &input_file) + .await?; if let Some(callback) = &options.on_progress { callback(UploadProgress { @@ -773,7 +838,15 @@ impl Client { return Ok(result); } - self.chunked_file_upload_with_progress(path, headers, params, param_name, &input_file, options).await + self.chunked_file_upload_with_progress( + path, + headers, + params, + param_name, + &input_file, + options, + ) + .await } async fn single_file_upload( @@ -793,8 +866,9 @@ impl Client { .file_name(input_file.filename().to_string()); if let Some(mime_type) = input_file.mime_type() { - file_part = file_part.mime_str(mime_type) - .map_err(|e| AppwriteError::new(0, format!("Invalid MIME type: {}", e), None, String::new()))?; + file_part = file_part.mime_str(mime_type).map_err(|e| { + AppwriteError::new(0, format!("Invalid MIME type: {}", e), None, String::new()) + })?; } form = form.part(param_name.to_string(), file_part); @@ -821,11 +895,7 @@ impl Client { } } - let response = request_builder - .multipart(form) - .send() - .await - ?; + let response = request_builder.multipart(form).send().await?; self.handle_response(response).await } @@ -852,13 +922,13 @@ impl Client { let mut start_chunk = 0u64; let mut last_response = None; if let Some(ref id) = current_upload_id { - if let Ok(response) = self.call::( - Method::GET, - &format!("{}/{}", path, id), - None, - None, - ).await { - if let Some(chunks_uploaded) = response.get("chunksUploaded").and_then(|v| v.as_u64()) { + if let Ok(response) = self + .call::(Method::GET, &format!("{}/{}", path, id), None, None) + .await + { + if let Some(chunks_uploaded) = + response.get("chunksUploaded").and_then(|v| v.as_u64()) + { start_chunk = chunks_uploaded; } last_response = Some(response.clone()); @@ -871,7 +941,8 @@ impl Client { let mut completed_response = None; let is_upload_complete = |response: &Value| -> bool { - let Some(chunks_uploaded) = response.get("chunksUploaded").and_then(|v| v.as_u64()) else { + let Some(chunks_uploaded) = response.get("chunksUploaded").and_then(|v| v.as_u64()) + else { return false; }; let chunks_total = response @@ -883,17 +954,19 @@ impl Client { }; if next_chunk == 0 { - let result = self.upload_file_chunk( - path, - headers.clone(), - params.clone(), - param_name, - input_file, - current_upload_id.clone(), - 0, - file_size, - chunk_size, - ).await?; + let result = self + .upload_file_chunk( + path, + headers.clone(), + params.clone(), + param_name, + input_file, + current_upload_id.clone(), + 0, + file_size, + chunk_size, + ) + .await?; if let Some(id) = result.get("$id").and_then(|v| v.as_str()) { current_upload_id = Some(id.to_string()); @@ -932,17 +1005,19 @@ impl Client { let chunk_index = next_chunk; tasks.spawn(async move { - let result = client.upload_file_chunk( - &path, - headers, - params, - ¶m_name, - &input_file, - upload_id, - chunk_index, - file_size, - chunk_size, - ).await?; + let result = client + .upload_file_chunk( + &path, + headers, + params, + ¶m_name, + &input_file, + upload_id, + chunk_index, + file_size, + chunk_size, + ) + .await?; Ok::<_, AppwriteError>((chunk_index, result)) }); @@ -950,8 +1025,14 @@ impl Client { } while let Some(joined) = tasks.join_next().await { - let (chunk_index, result) = joined - .map_err(|e| AppwriteError::new(0, format!("Chunk upload task failed: {}", e), None, String::new()))??; + let (chunk_index, result) = joined.map_err(|e| { + AppwriteError::new( + 0, + format!("Chunk upload task failed: {}", e), + None, + String::new(), + ) + })??; last_response = Some(result.clone()); if is_upload_complete(&result) { @@ -983,17 +1064,19 @@ impl Client { let chunk_index = next_chunk; tasks.spawn(async move { - let result = client.upload_file_chunk( - &path, - headers, - params, - ¶m_name, - &input_file, - upload_id, - chunk_index, - file_size, - chunk_size, - ).await?; + let result = client + .upload_file_chunk( + &path, + headers, + params, + ¶m_name, + &input_file, + upload_id, + chunk_index, + file_size, + chunk_size, + ) + .await?; Ok::<_, AppwriteError>((chunk_index, result)) }); @@ -1030,17 +1113,24 @@ impl Client { let actual_chunk_size = chunk_data.len(); if actual_chunk_size == 0 { - return Err(AppwriteError::new(0, "Chunk data is empty", None, String::new())); + return Err(AppwriteError::new( + 0, + "Chunk data is empty", + None, + String::new(), + )); } let state = self.state.load_full(); let mut form = multipart::Form::new(); - let mut file_part = multipart::Part::stream_with_length(chunk_data, actual_chunk_size as u64) - .file_name(input_file.filename().to_string()); + let mut file_part = + multipart::Part::stream_with_length(chunk_data, actual_chunk_size as u64) + .file_name(input_file.filename().to_string()); if let Some(mime_type) = input_file.mime_type() { - file_part = file_part.mime_str(mime_type) - .map_err(|e| AppwriteError::new(0, format!("Invalid MIME type: {}", e), None, String::new()))?; + file_part = file_part.mime_str(mime_type).map_err(|e| { + AppwriteError::new(0, format!("Invalid MIME type: {}", e), None, String::new()) + })?; } form = form.part(param_name.to_string(), file_part); @@ -1076,10 +1166,7 @@ impl Client { let content_range = format!("bytes {}-{}/{}", start, chunk_end, file_size); request_builder = request_builder.header("content-range", content_range); - let response = request_builder - .multipart(form) - .send() - .await?; + let response = request_builder.multipart(form).send().await?; self.handle_response(response).await } @@ -1097,10 +1184,16 @@ impl Client { if status.is_success() { let bytes = response.bytes().await?; - if !content_type.is_empty() && !content_type.starts_with("application/json") && !bytes.is_empty() { + if !content_type.is_empty() + && !content_type.starts_with("application/json") + && !bytes.is_empty() + { return Err(AppwriteError::new( status.as_u16(), - format!("Expected JSON response but received content-type: {}", content_type), + format!( + "Expected JSON response but received content-type: {}", + content_type + ), None, String::from_utf8_lossy(&bytes).to_string(), )); diff --git a/src/enums/build_runtime.rs b/src/enums/build_runtime.rs index 8e623ac..91ffc1b 100644 --- a/src/enums/build_runtime.rs +++ b/src/enums/build_runtime.rs @@ -159,6 +159,8 @@ pub enum BuildRuntime { Bun12, #[serde(rename = "bun-1.3")] Bun13, + #[serde(rename = "bun-1.4")] + Bun14, #[serde(rename = "go-1.23")] Go123, #[serde(rename = "go-1.24")] @@ -271,6 +273,7 @@ impl BuildRuntime { BuildRuntime::Bun11 => "bun-1.1", BuildRuntime::Bun12 => "bun-1.2", BuildRuntime::Bun13 => "bun-1.3", + BuildRuntime::Bun14 => "bun-1.4", BuildRuntime::Go123 => "go-1.23", BuildRuntime::Go124 => "go-1.24", BuildRuntime::Go125 => "go-1.25", diff --git a/src/enums/documents_db_index_type.rs b/src/enums/documents_db_index_type.rs new file mode 100644 index 0000000..b8201e3 --- /dev/null +++ b/src/enums/documents_db_index_type.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum DocumentsDBIndexType { + #[serde(rename = "key")] + #[default] + Key, + #[serde(rename = "fulltext")] + Fulltext, + #[serde(rename = "unique")] + Unique, +} + +impl DocumentsDBIndexType { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + DocumentsDBIndexType::Key => "key", + DocumentsDBIndexType::Fulltext => "fulltext", + DocumentsDBIndexType::Unique => "unique", + } + } +} + +impl std::fmt::Display for DocumentsDBIndexType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/embedding_model.rs b/src/enums/embedding_model.rs index 6b782c8..8619c21 100644 --- a/src/enums/embedding_model.rs +++ b/src/enums/embedding_model.rs @@ -5,12 +5,8 @@ pub enum EmbeddingModel { #[serde(rename = "nomic-embed-text")] #[default] NomicEmbedText, - #[serde(rename = "embedding-gemma")] - EmbeddingGemma, #[serde(rename = "all-minilm")] AllMinilm, - #[serde(rename = "bge-small")] - BgeSmall, } impl EmbeddingModel { @@ -18,9 +14,7 @@ impl EmbeddingModel { pub fn as_str(&self) -> &str { match self { EmbeddingModel::NomicEmbedText => "nomic-embed-text", - EmbeddingModel::EmbeddingGemma => "embedding-gemma", EmbeddingModel::AllMinilm => "all-minilm", - EmbeddingModel::BgeSmall => "bge-small", } } } diff --git a/src/enums/execution_resource_type.rs b/src/enums/execution_resource_type.rs new file mode 100644 index 0000000..ab94e86 --- /dev/null +++ b/src/enums/execution_resource_type.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum ExecutionResourceType { + #[serde(rename = "functions")] + #[default] + Functions, + #[serde(rename = "sites")] + Sites, +} + +impl ExecutionResourceType { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + ExecutionResourceType::Functions => "functions", + ExecutionResourceType::Sites => "sites", + } + } +} + +impl std::fmt::Display for ExecutionResourceType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/enums/mod.rs b/src/enums/mod.rs index 0a0aff8..7f04bf1 100644 --- a/src/enums/mod.rs +++ b/src/enums/mod.rs @@ -30,6 +30,8 @@ pub mod databases_index_type; pub use databases_index_type::DatabasesIndexType; pub mod order_by; pub use order_by::OrderBy; +pub mod documents_db_index_type; +pub use documents_db_index_type::DocumentsDBIndexType; pub mod embedding_model; pub use embedding_model::EmbeddingModel; pub mod runtime; @@ -94,6 +96,8 @@ pub mod password_hash; pub use password_hash::PasswordHash; pub mod messaging_provider_type; pub use messaging_provider_type::MessagingProviderType; +pub mod vectors_db_index_type; +pub use vectors_db_index_type::VectorsDBIndexType; pub mod database_type; pub use database_type::DatabaseType; pub mod database_status; @@ -106,6 +110,8 @@ pub mod index_status; pub use index_status::IndexStatus; pub mod deployment_status; pub use deployment_status::DeploymentStatus; +pub mod execution_resource_type; +pub use execution_resource_type::ExecutionResourceType; pub mod execution_trigger; pub use execution_trigger::ExecutionTrigger; pub mod execution_status; diff --git a/src/enums/o_auth_provider.rs b/src/enums/o_auth_provider.rs index e4142f2..aae5587 100644 --- a/src/enums/o_auth_provider.rs +++ b/src/enums/o_auth_provider.rs @@ -43,6 +43,8 @@ pub enum OAuthProvider { Gitlab, #[serde(rename = "google")] Google, + #[serde(rename = "huggingface")] + Huggingface, #[serde(rename = "keycloak")] Keycloak, #[serde(rename = "kick")] @@ -117,6 +119,7 @@ impl OAuthProvider { OAuthProvider::Github => "github", OAuthProvider::Gitlab => "gitlab", OAuthProvider::Google => "google", + OAuthProvider::Huggingface => "huggingface", OAuthProvider::Keycloak => "keycloak", OAuthProvider::Kick => "kick", OAuthProvider::Linkedin => "linkedin", diff --git a/src/enums/organization_key_scopes.rs b/src/enums/organization_key_scopes.rs index bc92a1e..7844c9b 100644 --- a/src/enums/organization_key_scopes.rs +++ b/src/enums/organization_key_scopes.rs @@ -47,8 +47,12 @@ impl OrganizationKeyScopes { OrganizationKeyScopes::DevKeysWrite => "devKeys.write", OrganizationKeyScopes::OrganizationKeysRead => "organization.keys.read", OrganizationKeyScopes::OrganizationKeysWrite => "organization.keys.write", - OrganizationKeyScopes::OrganizationInstallationsRead => "organization.installations.read", - OrganizationKeyScopes::OrganizationInstallationsWrite => "organization.installations.write", + OrganizationKeyScopes::OrganizationInstallationsRead => { + "organization.installations.read" + } + OrganizationKeyScopes::OrganizationInstallationsWrite => { + "organization.installations.write" + } OrganizationKeyScopes::OrganizationMembershipsRead => "organization.memberships.read", OrganizationKeyScopes::OrganizationMembershipsWrite => "organization.memberships.write", OrganizationKeyScopes::OrganizationRead => "organization.read", diff --git a/src/enums/project_key_scopes.rs b/src/enums/project_key_scopes.rs index b04d702..e29759a 100644 --- a/src/enums/project_key_scopes.rs +++ b/src/enums/project_key_scopes.rs @@ -7,6 +7,8 @@ pub enum ProjectKeyScopes { ProjectRead, #[serde(rename = "project.write")] ProjectWrite, + #[serde(rename = "usage.read")] + UsageRead, #[serde(rename = "keys.read")] KeysRead, #[serde(rename = "keys.write")] @@ -85,6 +87,30 @@ pub enum ProjectKeyScopes { DocumentsRead, #[serde(rename = "documents.write")] DocumentsWrite, + #[serde(rename = "documentsdb.read")] + DocumentsdbRead, + #[serde(rename = "documentsdb.write")] + DocumentsdbWrite, + #[serde(rename = "documentsdb.collections.read")] + DocumentsdbCollectionsRead, + #[serde(rename = "documentsdb.collections.write")] + DocumentsdbCollectionsWrite, + #[serde(rename = "documentsdb.documents.read")] + DocumentsdbDocumentsRead, + #[serde(rename = "documentsdb.documents.write")] + DocumentsdbDocumentsWrite, + #[serde(rename = "vectorsdb.read")] + VectorsdbRead, + #[serde(rename = "vectorsdb.write")] + VectorsdbWrite, + #[serde(rename = "vectorsdb.collections.read")] + VectorsdbCollectionsRead, + #[serde(rename = "vectorsdb.collections.write")] + VectorsdbCollectionsWrite, + #[serde(rename = "vectorsdb.documents.read")] + VectorsdbDocumentsRead, + #[serde(rename = "vectorsdb.documents.write")] + VectorsdbDocumentsWrite, #[serde(rename = "buckets.read")] BucketsRead, #[serde(rename = "buckets.write")] @@ -189,8 +215,6 @@ pub enum ProjectKeyScopes { RestorationsRead, #[serde(rename = "restorations.write")] RestorationsWrite, - #[serde(rename = "dedicatedDatabases.execute")] - DedicatedDatabasesExecute, #[serde(rename = "domains.read")] DomainsRead, #[serde(rename = "domains.write")] @@ -213,8 +237,6 @@ pub enum ProjectKeyScopes { Oauth2Write, #[serde(rename = "oauth2.introspect")] Oauth2Introspect, - #[serde(rename = "usage.read")] - UsageRead, } impl ProjectKeyScopes { @@ -223,6 +245,7 @@ impl ProjectKeyScopes { match self { ProjectKeyScopes::ProjectRead => "project.read", ProjectKeyScopes::ProjectWrite => "project.write", + ProjectKeyScopes::UsageRead => "usage.read", ProjectKeyScopes::KeysRead => "keys.read", ProjectKeyScopes::KeysWrite => "keys.write", ProjectKeyScopes::PlatformsRead => "platforms.read", @@ -262,6 +285,18 @@ impl ProjectKeyScopes { ProjectKeyScopes::AttributesWrite => "attributes.write", ProjectKeyScopes::DocumentsRead => "documents.read", ProjectKeyScopes::DocumentsWrite => "documents.write", + ProjectKeyScopes::DocumentsdbRead => "documentsdb.read", + ProjectKeyScopes::DocumentsdbWrite => "documentsdb.write", + ProjectKeyScopes::DocumentsdbCollectionsRead => "documentsdb.collections.read", + ProjectKeyScopes::DocumentsdbCollectionsWrite => "documentsdb.collections.write", + ProjectKeyScopes::DocumentsdbDocumentsRead => "documentsdb.documents.read", + ProjectKeyScopes::DocumentsdbDocumentsWrite => "documentsdb.documents.write", + ProjectKeyScopes::VectorsdbRead => "vectorsdb.read", + ProjectKeyScopes::VectorsdbWrite => "vectorsdb.write", + ProjectKeyScopes::VectorsdbCollectionsRead => "vectorsdb.collections.read", + ProjectKeyScopes::VectorsdbCollectionsWrite => "vectorsdb.collections.write", + ProjectKeyScopes::VectorsdbDocumentsRead => "vectorsdb.documents.read", + ProjectKeyScopes::VectorsdbDocumentsWrite => "vectorsdb.documents.write", ProjectKeyScopes::BucketsRead => "buckets.read", ProjectKeyScopes::BucketsWrite => "buckets.write", ProjectKeyScopes::FilesRead => "files.read", @@ -314,7 +349,6 @@ impl ProjectKeyScopes { ProjectKeyScopes::ArchivesWrite => "archives.write", ProjectKeyScopes::RestorationsRead => "restorations.read", ProjectKeyScopes::RestorationsWrite => "restorations.write", - ProjectKeyScopes::DedicatedDatabasesExecute => "dedicatedDatabases.execute", ProjectKeyScopes::DomainsRead => "domains.read", ProjectKeyScopes::DomainsWrite => "domains.write", ProjectKeyScopes::WafRulesRead => "wafRules.read", @@ -326,7 +360,6 @@ impl ProjectKeyScopes { ProjectKeyScopes::Oauth2Read => "oauth2.read", ProjectKeyScopes::Oauth2Write => "oauth2.write", ProjectKeyScopes::Oauth2Introspect => "oauth2.introspect", - ProjectKeyScopes::UsageRead => "usage.read", } } } diff --git a/src/enums/project_o_auth_provider_id.rs b/src/enums/project_o_auth_provider_id.rs index 6bb913b..75a4439 100644 --- a/src/enums/project_o_auth_provider_id.rs +++ b/src/enums/project_o_auth_provider_id.rs @@ -43,6 +43,8 @@ pub enum ProjectOAuthProviderId { Gitlab, #[serde(rename = "google")] Google, + #[serde(rename = "huggingface")] + Huggingface, #[serde(rename = "keycloak")] Keycloak, #[serde(rename = "kick")] @@ -117,6 +119,7 @@ impl ProjectOAuthProviderId { ProjectOAuthProviderId::Github => "github", ProjectOAuthProviderId::Gitlab => "gitlab", ProjectOAuthProviderId::Google => "google", + ProjectOAuthProviderId::Huggingface => "huggingface", ProjectOAuthProviderId::Keycloak => "keycloak", ProjectOAuthProviderId::Kick => "kick", ProjectOAuthProviderId::Linkedin => "linkedin", diff --git a/src/enums/runtime.rs b/src/enums/runtime.rs index 762d1b8..cd554d8 100644 --- a/src/enums/runtime.rs +++ b/src/enums/runtime.rs @@ -159,6 +159,8 @@ pub enum Runtime { Bun12, #[serde(rename = "bun-1.3")] Bun13, + #[serde(rename = "bun-1.4")] + Bun14, #[serde(rename = "go-1.23")] Go123, #[serde(rename = "go-1.24")] @@ -271,6 +273,7 @@ impl Runtime { Runtime::Bun11 => "bun-1.1", Runtime::Bun12 => "bun-1.2", Runtime::Bun13 => "bun-1.3", + Runtime::Bun14 => "bun-1.4", Runtime::Go123 => "go-1.23", Runtime::Go124 => "go-1.24", Runtime::Go125 => "go-1.25", diff --git a/src/enums/vectors_db_index_type.rs b/src/enums/vectors_db_index_type.rs new file mode 100644 index 0000000..bff4ca7 --- /dev/null +++ b/src/enums/vectors_db_index_type.rs @@ -0,0 +1,38 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] +pub enum VectorsDBIndexType { + #[serde(rename = "hnsw_euclidean")] + #[default] + HnswEuclidean, + #[serde(rename = "hnsw_dot")] + HnswDot, + #[serde(rename = "hnsw_cosine")] + HnswCosine, + #[serde(rename = "object")] + Object, + #[serde(rename = "key")] + Key, + #[serde(rename = "unique")] + Unique, +} + +impl VectorsDBIndexType { + /// Get the string value of the enum + pub fn as_str(&self) -> &str { + match self { + VectorsDBIndexType::HnswEuclidean => "hnsw_euclidean", + VectorsDBIndexType::HnswDot => "hnsw_dot", + VectorsDBIndexType::HnswCosine => "hnsw_cosine", + VectorsDBIndexType::Object => "object", + VectorsDBIndexType::Key => "key", + VectorsDBIndexType::Unique => "unique", + } + } +} + +impl std::fmt::Display for VectorsDBIndexType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/error.rs b/src/error.rs index 8715cb4..8ee8a9b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -16,7 +16,12 @@ pub struct AppwriteError { } impl AppwriteError { - pub fn new(code: u16, message: impl Into, error_type: Option, response: impl Into) -> Self { + pub fn new( + code: u16, + message: impl Into, + error_type: Option, + response: impl Into, + ) -> Self { Self { code, message: message.into(), @@ -59,7 +64,12 @@ impl From for AppwriteError { impl From for AppwriteError { fn from(err: serde_json::Error) -> Self { - Self::new(0, format!("Serialization error: {}", err), None, String::new()) + Self::new( + 0, + format!("Serialization error: {}", err), + None, + String::new(), + ) } } @@ -84,12 +94,7 @@ mod tests { #[test] fn test_client_error() { - let error = AppwriteError::new( - 404, - "Not found", - None, - "{}", - ); + let error = AppwriteError::new(404, "Not found", None, "{}"); assert_eq!(error.status_code(), 404); assert_eq!(error.get_message(), "Not found"); @@ -99,12 +104,7 @@ mod tests { #[test] fn test_server_error() { - let error = AppwriteError::new( - 500, - "Internal server error", - None, - "{}", - ); + let error = AppwriteError::new(500, "Internal server error", None, "{}"); assert!(error.is_server_error()); assert!(!error.is_client_error()); diff --git a/src/input_file.rs b/src/input_file.rs index e72b3c1..bcfddc4 100644 --- a/src/input_file.rs +++ b/src/input_file.rs @@ -63,7 +63,9 @@ impl InputFile { .to_string(); Ok(Self { - source: InputFileSource::Path { path: path.to_path_buf() }, + source: InputFileSource::Path { + path: path.to_path_buf(), + }, filename, mime_type: mime_type.map(|s| s.to_string()), }) @@ -80,7 +82,9 @@ impl InputFile { .to_string(); Ok(Self { - source: InputFileSource::Path { path: path.to_path_buf() }, + source: InputFileSource::Path { + path: path.to_path_buf(), + }, filename, mime_type: mime_type.map(|s| s.to_string()), }) @@ -101,27 +105,21 @@ impl InputFile { pub async fn size(&self) -> Result { match &self.source { InputFileSource::Bytes { data } => Ok(data.len() as u64), - InputFileSource::Path { path } => { - Ok(fs::metadata(path).await?.len()) - } + InputFileSource::Path { path } => Ok(fs::metadata(path).await?.len()), } } pub fn size_sync(&self) -> Result { match &self.source { InputFileSource::Bytes { data } => Ok(data.len() as u64), - InputFileSource::Path { path } => { - Ok(std::fs::metadata(path)?.len()) - } + InputFileSource::Path { path } => Ok(std::fs::metadata(path)?.len()), } } pub async fn read_all(&self) -> Result { match &self.source { InputFileSource::Bytes { data } => Ok(data.clone()), - InputFileSource::Path { path } => { - Ok(Bytes::from(fs::read(path).await?)) - } + InputFileSource::Path { path } => Ok(Bytes::from(fs::read(path).await?)), } } @@ -137,14 +135,12 @@ impl InputFile { total_size, }) } - InputFileSource::Bytes { data } => { - Ok(ChunkedReader { - file: None, - data: Some(data.clone()), - position: 0, - total_size: data.len() as u64, - }) - } + InputFileSource::Bytes { data } => Ok(ChunkedReader { + file: None, + data: Some(data.clone()), + position: 0, + total_size: data.len() as u64, + }), } } @@ -163,11 +159,9 @@ impl InputFile { pub fn is_empty(&self) -> bool { match &self.source { InputFileSource::Bytes { data } => data.is_empty(), - InputFileSource::Path { path } => { - std::fs::metadata(path) - .map(|m| m.len() == 0) - .unwrap_or(true) - } + InputFileSource::Path { path } => std::fs::metadata(path) + .map(|m| m.len() == 0) + .unwrap_or(true), } } } @@ -232,7 +226,10 @@ impl ChunkedReader { if position > self.total_size { return Err(crate::error::AppwriteError::new( 0, - format!("Seek position {} exceeds file size {}", position, self.total_size), + format!( + "Seek position {} exceeds file size {}", + position, self.total_size + ), None, String::new(), )); diff --git a/src/lib.rs b/src/lib.rs index f02b644..fb24fa9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! //! ```toml //! [dependencies] -//! appwrite = "0.13.0" +//! appwrite = "0.14.0-rc.1" //! ``` //! //! ## Usage @@ -51,7 +51,7 @@ pub use input_file::InputFile; pub type Result = std::result::Result; /// SDK version -pub const VERSION: &str = "0.13.0"; +pub const VERSION: &str = "0.14.0-rc.1"; /// SDK name pub const SDK_NAME: &str = "Rust"; diff --git a/src/models/activity_event.rs b/src/models/activity_event.rs index d164290..5590142 100644 --- a/src/models/activity_event.rs +++ b/src/models/activity_event.rs @@ -240,7 +240,6 @@ impl ActivityEvent { pub fn sdk_version(&self) -> &String { &self.sdk_version } - } #[cfg(test)] diff --git a/src/models/activity_event_list.rs b/src/models/activity_event_list.rs index 4d989db..a83d557 100644 --- a/src/models/activity_event_list.rs +++ b/src/models/activity_event_list.rs @@ -24,7 +24,6 @@ impl ActivityEventList { pub fn events(&self) -> &Vec { &self.events } - } #[cfg(test)] diff --git a/src/models/additional_resource.rs b/src/models/additional_resource.rs index ed69cd4..bf02523 100644 --- a/src/models/additional_resource.rs +++ b/src/models/additional_resource.rs @@ -56,7 +56,6 @@ impl AdditionalResource { pub fn invoice_desc(&self) -> &String { &self.invoice_desc } - } #[cfg(test)] diff --git a/src/models/algo_argon2.rs b/src/models/algo_argon2.rs index 542f5db..c4e4c7e 100644 --- a/src/models/algo_argon2.rs +++ b/src/models/algo_argon2.rs @@ -40,7 +40,6 @@ impl AlgoArgon2 { pub fn threads(&self) -> &i64 { &self.threads } - } #[cfg(test)] diff --git a/src/models/algo_bcrypt.rs b/src/models/algo_bcrypt.rs index c1a832a..acbd333 100644 --- a/src/models/algo_bcrypt.rs +++ b/src/models/algo_bcrypt.rs @@ -16,7 +16,6 @@ impl AlgoBcrypt { pub fn r#type(&self) -> &String { &self.r#type } - } #[cfg(test)] diff --git a/src/models/algo_md5.rs b/src/models/algo_md5.rs index d73a007..babd088 100644 --- a/src/models/algo_md5.rs +++ b/src/models/algo_md5.rs @@ -16,7 +16,6 @@ impl AlgoMd5 { pub fn r#type(&self) -> &String { &self.r#type } - } #[cfg(test)] diff --git a/src/models/algo_phpass.rs b/src/models/algo_phpass.rs index f2aae71..8227738 100644 --- a/src/models/algo_phpass.rs +++ b/src/models/algo_phpass.rs @@ -16,7 +16,6 @@ impl AlgoPhpass { pub fn r#type(&self) -> &String { &self.r#type } - } #[cfg(test)] diff --git a/src/models/algo_scrypt.rs b/src/models/algo_scrypt.rs index d6123f0..86a424a 100644 --- a/src/models/algo_scrypt.rs +++ b/src/models/algo_scrypt.rs @@ -48,7 +48,6 @@ impl AlgoScrypt { pub fn length(&self) -> &i64 { &self.length } - } #[cfg(test)] diff --git a/src/models/algo_scrypt_modified.rs b/src/models/algo_scrypt_modified.rs index 2f273b4..3722ebd 100644 --- a/src/models/algo_scrypt_modified.rs +++ b/src/models/algo_scrypt_modified.rs @@ -40,7 +40,6 @@ impl AlgoScryptModified { pub fn signer_key(&self) -> &String { &self.signer_key } - } #[cfg(test)] diff --git a/src/models/algo_sha.rs b/src/models/algo_sha.rs index 08b454e..e8aa8fb 100644 --- a/src/models/algo_sha.rs +++ b/src/models/algo_sha.rs @@ -16,7 +16,6 @@ impl AlgoSha { pub fn r#type(&self) -> &String { &self.r#type } - } #[cfg(test)] diff --git a/src/models/app.rs b/src/models/app.rs index 4a89d49..35791b2 100644 --- a/src/models/app.rs +++ b/src/models/app.rs @@ -227,7 +227,6 @@ impl App { pub fn secrets(&self) -> &Vec { &self.secrets } - } #[cfg(test)] diff --git a/src/models/app_installation.rs b/src/models/app_installation.rs index fa3463d..7ad4193 100644 --- a/src/models/app_installation.rs +++ b/src/models/app_installation.rs @@ -30,7 +30,7 @@ pub struct AppInstallation { /// request (RFC 9396) style entries; the Appwrite Console stores authorized /// project IDs here. #[serde(rename = "authorizationDetails")] - pub authorization_details: serde_json::Value, + pub authorization_details: Vec, /// ID of the user who created the installation. #[serde(rename = "createdById")] pub created_by_id: String, @@ -76,7 +76,7 @@ impl AppInstallation { } /// Get authorization_details - pub fn authorization_details(&self) -> &serde_json::Value { + pub fn authorization_details(&self) -> &Vec { &self.authorization_details } @@ -100,7 +100,6 @@ impl AppInstallation { pub fn last_accessed_at(&self) -> Option<&String> { self.last_accessed_at.as_ref() } - } #[cfg(test)] diff --git a/src/models/app_installation_list.rs b/src/models/app_installation_list.rs index 4c535c3..aa427f0 100644 --- a/src/models/app_installation_list.rs +++ b/src/models/app_installation_list.rs @@ -24,7 +24,6 @@ impl AppInstallationList { pub fn installations(&self) -> &Vec { &self.installations } - } #[cfg(test)] diff --git a/src/models/app_key.rs b/src/models/app_key.rs index fabd8d4..cbfbbd0 100644 --- a/src/models/app_key.rs +++ b/src/models/app_key.rs @@ -88,7 +88,6 @@ impl AppKey { pub fn last_accessed_at(&self) -> Option<&String> { self.last_accessed_at.as_ref() } - } #[cfg(test)] diff --git a/src/models/app_key_list.rs b/src/models/app_key_list.rs index d55fd4a..232fa6f 100644 --- a/src/models/app_key_list.rs +++ b/src/models/app_key_list.rs @@ -24,7 +24,6 @@ impl AppKeyList { pub fn keys(&self) -> &Vec { &self.keys } - } #[cfg(test)] diff --git a/src/models/app_scope.rs b/src/models/app_scope.rs index 9143914..7f14082 100644 --- a/src/models/app_scope.rs +++ b/src/models/app_scope.rs @@ -50,7 +50,6 @@ impl AppScope { pub fn deprecated(&self) -> &bool { &self.deprecated } - } #[cfg(test)] diff --git a/src/models/app_scope_list.rs b/src/models/app_scope_list.rs index f3ec1ca..0d93b62 100644 --- a/src/models/app_scope_list.rs +++ b/src/models/app_scope_list.rs @@ -24,7 +24,6 @@ impl AppScopeList { pub fn scopes(&self) -> &Vec { &self.scopes } - } #[cfg(test)] diff --git a/src/models/app_secret.rs b/src/models/app_secret.rs index e78d44f..a32282b 100644 --- a/src/models/app_secret.rs +++ b/src/models/app_secret.rs @@ -89,7 +89,6 @@ impl AppSecret { pub fn last_accessed_at(&self) -> Option<&String> { self.last_accessed_at.as_ref() } - } #[cfg(test)] diff --git a/src/models/app_secret_list.rs b/src/models/app_secret_list.rs index ccf95f1..f9df34d 100644 --- a/src/models/app_secret_list.rs +++ b/src/models/app_secret_list.rs @@ -24,7 +24,6 @@ impl AppSecretList { pub fn secrets(&self) -> &Vec { &self.secrets } - } #[cfg(test)] diff --git a/src/models/app_secret_plaintext.rs b/src/models/app_secret_plaintext.rs index e4bf9ea..4c7a292 100644 --- a/src/models/app_secret_plaintext.rs +++ b/src/models/app_secret_plaintext.rs @@ -89,7 +89,6 @@ impl AppSecretPlaintext { pub fn last_accessed_at(&self) -> Option<&String> { self.last_accessed_at.as_ref() } - } #[cfg(test)] diff --git a/src/models/apps_list.rs b/src/models/apps_list.rs index cf17285..6f31208 100644 --- a/src/models/apps_list.rs +++ b/src/models/apps_list.rs @@ -24,7 +24,6 @@ impl AppsList { pub fn apps(&self) -> &Vec { &self.apps } - } #[cfg(test)] diff --git a/src/models/attribute_bigint.rs b/src/models/attribute_bigint.rs index 847f356..7dffebc 100644 --- a/src/models/attribute_bigint.rs +++ b/src/models/attribute_bigint.rs @@ -127,7 +127,6 @@ impl AttributeBigint { pub fn default(&self) -> Option<&i64> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_boolean.rs b/src/models/attribute_boolean.rs index eebc91a..e6ddcc3 100644 --- a/src/models/attribute_boolean.rs +++ b/src/models/attribute_boolean.rs @@ -97,7 +97,6 @@ impl AttributeBoolean { pub fn default(&self) -> Option<&bool> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_datetime.rs b/src/models/attribute_datetime.rs index 0eb6bc8..beacd6d 100644 --- a/src/models/attribute_datetime.rs +++ b/src/models/attribute_datetime.rs @@ -104,7 +104,6 @@ impl AttributeDatetime { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_email.rs b/src/models/attribute_email.rs index 9780b8d..2f172f7 100644 --- a/src/models/attribute_email.rs +++ b/src/models/attribute_email.rs @@ -105,7 +105,6 @@ impl AttributeEmail { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_enum.rs b/src/models/attribute_enum.rs index 6ebc2cf..f78d0eb 100644 --- a/src/models/attribute_enum.rs +++ b/src/models/attribute_enum.rs @@ -113,7 +113,6 @@ impl AttributeEnum { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_float.rs b/src/models/attribute_float.rs index c8fea5c..49cda73 100644 --- a/src/models/attribute_float.rs +++ b/src/models/attribute_float.rs @@ -127,7 +127,6 @@ impl AttributeFloat { pub fn default(&self) -> Option<&f64> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_integer.rs b/src/models/attribute_integer.rs index 357c12f..39cad56 100644 --- a/src/models/attribute_integer.rs +++ b/src/models/attribute_integer.rs @@ -127,7 +127,6 @@ impl AttributeInteger { pub fn default(&self) -> Option<&i64> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_ip.rs b/src/models/attribute_ip.rs index 2bb821a..2328c38 100644 --- a/src/models/attribute_ip.rs +++ b/src/models/attribute_ip.rs @@ -105,7 +105,6 @@ impl AttributeIp { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_line.rs b/src/models/attribute_line.rs index b54db25..975994b 100644 --- a/src/models/attribute_line.rs +++ b/src/models/attribute_line.rs @@ -97,7 +97,6 @@ impl AttributeLine { pub fn default(&self) -> Option<&Vec>> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_list.rs b/src/models/attribute_list.rs index e76e2b0..d405e6d 100644 --- a/src/models/attribute_list.rs +++ b/src/models/attribute_list.rs @@ -24,7 +24,6 @@ impl AttributeList { pub fn attributes(&self) -> &Vec { &self.attributes } - } #[cfg(test)] diff --git a/src/models/attribute_longtext.rs b/src/models/attribute_longtext.rs index addeefe..b613bf1 100644 --- a/src/models/attribute_longtext.rs +++ b/src/models/attribute_longtext.rs @@ -112,7 +112,6 @@ impl AttributeLongtext { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_mediumtext.rs b/src/models/attribute_mediumtext.rs index 9e1a79f..98fcecd 100644 --- a/src/models/attribute_mediumtext.rs +++ b/src/models/attribute_mediumtext.rs @@ -112,7 +112,6 @@ impl AttributeMediumtext { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_object.rs b/src/models/attribute_object.rs new file mode 100644 index 0000000..02515bf --- /dev/null +++ b/src/models/attribute_object.rs @@ -0,0 +1,111 @@ +//! AttributeObject model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// AttributeObject +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct AttributeObject { + /// Attribute Key. + #[serde(rename = "key")] + pub key: String, + /// Attribute type. + #[serde(rename = "type")] + pub r#type: String, + /// Attribute status. Possible values: `available`, `processing`, `deleting`, + /// `stuck`, or `failed` + #[serde(rename = "status")] + pub status: crate::enums::AttributeStatus, + /// Error message. Displays error generated on failure of creating or deleting + /// an attribute. + #[serde(rename = "error")] + pub error: String, + /// Is attribute required? + #[serde(rename = "required")] + pub required: bool, + /// Is attribute an array? + #[serde(rename = "array")] + #[serde(skip_serializing_if = "Option::is_none")] + pub array: Option, + /// Attribute creation date in ISO 8601 format. + #[serde(rename = "$createdAt")] + pub created_at: String, + /// Attribute update date in ISO 8601 format. + #[serde(rename = "$updatedAt")] + pub updated_at: String, +} + +impl AttributeObject { + /// Get key + pub fn key(&self) -> &String { + &self.key + } + + /// Get r#type + pub fn r#type(&self) -> &String { + &self.r#type + } + + /// Get status + pub fn status(&self) -> &crate::enums::AttributeStatus { + &self.status + } + + /// Get error + pub fn error(&self) -> &String { + &self.error + } + + /// Get required + pub fn required(&self) -> &bool { + &self.required + } + + /// Set array + pub fn set_array(mut self, array: bool) -> Self { + self.array = Some(array); + self + } + + /// Get array + pub fn array(&self) -> Option<&bool> { + self.array.as_ref() + } + + /// Get created_at + pub fn created_at(&self) -> &String { + &self.created_at + } + + /// Get updated_at + pub fn updated_at(&self) -> &String { + &self.updated_at + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_attribute_object_creation() { + let _model = ::default(); + let _ = _model.key(); + let _ = _model.r#type(); + let _ = _model.status(); + let _ = _model.error(); + let _ = _model.required(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + } + + #[test] + fn test_attribute_object_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/attribute_point.rs b/src/models/attribute_point.rs index 7314ff6..9ca02a2 100644 --- a/src/models/attribute_point.rs +++ b/src/models/attribute_point.rs @@ -97,7 +97,6 @@ impl AttributePoint { pub fn default(&self) -> Option<&Vec> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_polygon.rs b/src/models/attribute_polygon.rs index c7b0e8f..3d39979 100644 --- a/src/models/attribute_polygon.rs +++ b/src/models/attribute_polygon.rs @@ -97,7 +97,6 @@ impl AttributePolygon { pub fn default(&self) -> Option<&Vec>>> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_relationship.rs b/src/models/attribute_relationship.rs index ecd2d01..ce0efaf 100644 --- a/src/models/attribute_relationship.rs +++ b/src/models/attribute_relationship.rs @@ -129,7 +129,6 @@ impl AttributeRelationship { pub fn side(&self) -> &String { &self.side } - } #[cfg(test)] diff --git a/src/models/attribute_string.rs b/src/models/attribute_string.rs index 416c39d..93dc8bc 100644 --- a/src/models/attribute_string.rs +++ b/src/models/attribute_string.rs @@ -120,7 +120,6 @@ impl AttributeString { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_text.rs b/src/models/attribute_text.rs index ddfe094..838d477 100644 --- a/src/models/attribute_text.rs +++ b/src/models/attribute_text.rs @@ -112,7 +112,6 @@ impl AttributeText { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_url.rs b/src/models/attribute_url.rs index ceb7b16..4dfc86c 100644 --- a/src/models/attribute_url.rs +++ b/src/models/attribute_url.rs @@ -105,7 +105,6 @@ impl AttributeUrl { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_varchar.rs b/src/models/attribute_varchar.rs index 70ef75d..433fc29 100644 --- a/src/models/attribute_varchar.rs +++ b/src/models/attribute_varchar.rs @@ -120,7 +120,6 @@ impl AttributeVarchar { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/attribute_vector.rs b/src/models/attribute_vector.rs new file mode 100644 index 0000000..2472da9 --- /dev/null +++ b/src/models/attribute_vector.rs @@ -0,0 +1,120 @@ +//! AttributeVector model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// AttributeVector +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct AttributeVector { + /// Attribute Key. + #[serde(rename = "key")] + pub key: String, + /// Attribute type. + #[serde(rename = "type")] + pub r#type: String, + /// Attribute status. Possible values: `available`, `processing`, `deleting`, + /// `stuck`, or `failed` + #[serde(rename = "status")] + pub status: crate::enums::AttributeStatus, + /// Error message. Displays error generated on failure of creating or deleting + /// an attribute. + #[serde(rename = "error")] + pub error: String, + /// Is attribute required? + #[serde(rename = "required")] + pub required: bool, + /// Is attribute an array? + #[serde(rename = "array")] + #[serde(skip_serializing_if = "Option::is_none")] + pub array: Option, + /// Attribute creation date in ISO 8601 format. + #[serde(rename = "$createdAt")] + pub created_at: String, + /// Attribute update date in ISO 8601 format. + #[serde(rename = "$updatedAt")] + pub updated_at: String, + /// Vector dimensions. + #[serde(rename = "size")] + pub size: i64, +} + +impl AttributeVector { + /// Get key + pub fn key(&self) -> &String { + &self.key + } + + /// Get r#type + pub fn r#type(&self) -> &String { + &self.r#type + } + + /// Get status + pub fn status(&self) -> &crate::enums::AttributeStatus { + &self.status + } + + /// Get error + pub fn error(&self) -> &String { + &self.error + } + + /// Get required + pub fn required(&self) -> &bool { + &self.required + } + + /// Set array + pub fn set_array(mut self, array: bool) -> Self { + self.array = Some(array); + self + } + + /// Get array + pub fn array(&self) -> Option<&bool> { + self.array.as_ref() + } + + /// 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 size + pub fn size(&self) -> &i64 { + &self.size + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_attribute_vector_creation() { + let _model = ::default(); + let _ = _model.key(); + let _ = _model.r#type(); + let _ = _model.status(); + let _ = _model.error(); + let _ = _model.required(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.size(); + } + + #[test] + fn test_attribute_vector_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/backup_archive.rs b/src/models/backup_archive.rs index cc9fdbb..f4811a5 100644 --- a/src/models/backup_archive.rs +++ b/src/models/backup_archive.rs @@ -121,7 +121,6 @@ impl BackupArchive { pub fn resource_type(&self) -> Option<&String> { self.resource_type.as_ref() } - } #[cfg(test)] diff --git a/src/models/backup_archive_list.rs b/src/models/backup_archive_list.rs index ca94c96..46af024 100644 --- a/src/models/backup_archive_list.rs +++ b/src/models/backup_archive_list.rs @@ -24,7 +24,6 @@ impl BackupArchiveList { pub fn archives(&self) -> &Vec { &self.archives } - } #[cfg(test)] diff --git a/src/models/backup_policy.rs b/src/models/backup_policy.rs index 40f9010..0ee8535 100644 --- a/src/models/backup_policy.rs +++ b/src/models/backup_policy.rs @@ -121,7 +121,6 @@ impl BackupPolicy { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/backup_policy_list.rs b/src/models/backup_policy_list.rs index 07e5476..299f36b 100644 --- a/src/models/backup_policy_list.rs +++ b/src/models/backup_policy_list.rs @@ -24,7 +24,6 @@ impl BackupPolicyList { pub fn policies(&self) -> &Vec { &self.policies } - } #[cfg(test)] diff --git a/src/models/backup_restoration.rs b/src/models/backup_restoration.rs index 9fb005e..45931ed 100644 --- a/src/models/backup_restoration.rs +++ b/src/models/backup_restoration.rs @@ -97,7 +97,6 @@ impl BackupRestoration { pub fn options(&self) -> &String { &self.options } - } #[cfg(test)] diff --git a/src/models/backup_restoration_list.rs b/src/models/backup_restoration_list.rs index 6f33e1f..65c9ad3 100644 --- a/src/models/backup_restoration_list.rs +++ b/src/models/backup_restoration_list.rs @@ -24,7 +24,6 @@ impl BackupRestorationList { pub fn restorations(&self) -> &Vec { &self.restorations } - } #[cfg(test)] diff --git a/src/models/billing_limits.rs b/src/models/billing_limits.rs index ce1e0c5..2cafaac 100644 --- a/src/models/billing_limits.rs +++ b/src/models/billing_limits.rs @@ -128,7 +128,6 @@ impl BillingLimits { pub fn budget_limit(&self) -> Option<&i64> { self.budget_limit.as_ref() } - } #[cfg(test)] diff --git a/src/models/billing_plan.rs b/src/models/billing_plan.rs index 7e3d798..0243415 100644 --- a/src/models/billing_plan.rs +++ b/src/models/billing_plan.rs @@ -169,6 +169,9 @@ pub struct BillingPlan { /// Does plan support credit #[serde(rename = "supportsCredits")] pub supports_credits: bool, + /// Does plan support dedicated databases. + #[serde(rename = "supportsDedicatedDatabases")] + pub supports_dedicated_databases: bool, /// Does plan support blocking disposable email addresses. #[serde(rename = "supportsDisposableEmailValidation")] pub supports_disposable_email_validation: bool, @@ -218,6 +221,10 @@ pub struct BillingPlan { #[serde(rename = "program")] #[serde(skip_serializing_if = "Option::is_none")] pub program: Option, + /// Included monthly dedicated-database compute credit in USD. Resets each + /// billing cycle with no roll-over. + #[serde(rename = "databaseComputeCredit")] + pub database_compute_credit: f64, /// Dedicated database limits available to this plan. #[serde(rename = "dedicatedDatabases")] #[serde(skip_serializing_if = "Option::is_none")] @@ -508,6 +515,11 @@ impl BillingPlan { &self.supports_credits } + /// Get supports_dedicated_databases + pub fn supports_dedicated_databases(&self) -> &bool { + &self.supports_dedicated_databases + } + /// Get supports_disposable_email_validation pub fn supports_disposable_email_validation(&self) -> &bool { &self.supports_disposable_email_validation @@ -607,17 +619,26 @@ impl BillingPlan { self.program.as_ref() } + /// Get database_compute_credit + pub fn database_compute_credit(&self) -> &f64 { + &self.database_compute_credit + } + /// Set dedicated_databases - pub fn set_dedicated_databases(mut self, dedicated_databases: crate::models::BillingPlanDedicatedDatabaseLimits) -> Self { + pub fn set_dedicated_databases( + mut self, + dedicated_databases: crate::models::BillingPlanDedicatedDatabaseLimits, + ) -> Self { self.dedicated_databases = Some(dedicated_databases); self } /// Get dedicated_databases - pub fn dedicated_databases(&self) -> Option<&crate::models::BillingPlanDedicatedDatabaseLimits> { + pub fn dedicated_databases( + &self, + ) -> Option<&crate::models::BillingPlanDedicatedDatabaseLimits> { self.dedicated_databases.as_ref() } - } #[cfg(test)] @@ -677,6 +698,7 @@ mod tests { let _ = _model.supports_mock_numbers(); let _ = _model.supports_organization_roles(); let _ = _model.supports_credits(); + let _ = _model.supports_dedicated_databases(); let _ = _model.supports_disposable_email_validation(); let _ = _model.supports_canonical_email_validation(); let _ = _model.supports_free_email_validation(); @@ -688,6 +710,7 @@ mod tests { let _ = _model.build_size(); let _ = _model.databases_allow_encrypt(); let _ = _model.group(); + let _ = _model.database_compute_credit(); } #[test] diff --git a/src/models/billing_plan_addon.rs b/src/models/billing_plan_addon.rs index d533a23..99354bf 100644 --- a/src/models/billing_plan_addon.rs +++ b/src/models/billing_plan_addon.rs @@ -38,7 +38,6 @@ impl BillingPlanAddon { pub fn projects(&self) -> Option<&crate::models::BillingPlanAddonDetails> { self.projects.as_ref() } - } #[cfg(test)] diff --git a/src/models/billing_plan_addon_details.rs b/src/models/billing_plan_addon_details.rs index 0796b7f..00aa018 100644 --- a/src/models/billing_plan_addon_details.rs +++ b/src/models/billing_plan_addon_details.rs @@ -79,7 +79,6 @@ impl BillingPlanAddonDetails { pub fn invoice_desc(&self) -> &String { &self.invoice_desc } - } #[cfg(test)] diff --git a/src/models/billing_plan_dedicated_database_limits.rs b/src/models/billing_plan_dedicated_database_limits.rs index 654dc22..73c1d9d 100644 --- a/src/models/billing_plan_dedicated_database_limits.rs +++ b/src/models/billing_plan_dedicated_database_limits.rs @@ -252,7 +252,10 @@ impl BillingPlanDedicatedDatabaseLimits { } /// Set max_sql_api_allowed_statements - pub fn set_max_sql_api_allowed_statements(mut self, max_sql_api_allowed_statements: i64) -> Self { + pub fn set_max_sql_api_allowed_statements( + mut self, + max_sql_api_allowed_statements: i64, + ) -> Self { self.max_sql_api_allowed_statements = Some(max_sql_api_allowed_statements); self } @@ -294,7 +297,6 @@ impl BillingPlanDedicatedDatabaseLimits { pub fn allowed_sync_modes(&self) -> Option<&Vec> { self.allowed_sync_modes.as_ref() } - } #[cfg(test)] @@ -312,7 +314,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/billing_plan_limits.rs b/src/models/billing_plan_limits.rs index 0bf5bdd..224a019 100644 --- a/src/models/billing_plan_limits.rs +++ b/src/models/billing_plan_limits.rs @@ -38,7 +38,6 @@ impl BillingPlanLimits { pub fn daily_credits(&self) -> Option<&i64> { self.daily_credits.as_ref() } - } #[cfg(test)] diff --git a/src/models/billing_plan_supported_addons.rs b/src/models/billing_plan_supported_addons.rs index 52f8639..af95b2d 100644 --- a/src/models/billing_plan_supported_addons.rs +++ b/src/models/billing_plan_supported_addons.rs @@ -32,7 +32,6 @@ impl BillingPlanSupportedAddons { pub fn premium_geo_db_org(&self) -> &bool { &self.premium_geo_db_org } - } #[cfg(test)] @@ -53,7 +52,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/block.rs b/src/models/block.rs index e6c0a6b..9bd4591 100644 --- a/src/models/block.rs +++ b/src/models/block.rs @@ -111,7 +111,6 @@ impl Block { pub fn billing_plan(&self) -> &String { &self.billing_plan } - } #[cfg(test)] diff --git a/src/models/bucket.rs b/src/models/bucket.rs index 150a3f4..8140e6a 100644 --- a/src/models/bucket.rs +++ b/src/models/bucket.rs @@ -124,7 +124,6 @@ impl Bucket { pub fn total_size(&self) -> &i64 { &self.total_size } - } #[cfg(test)] diff --git a/src/models/bucket_list.rs b/src/models/bucket_list.rs index 6ac9e69..0f76efc 100644 --- a/src/models/bucket_list.rs +++ b/src/models/bucket_list.rs @@ -24,7 +24,6 @@ impl BucketList { pub fn buckets(&self) -> &Vec { &self.buckets } - } #[cfg(test)] diff --git a/src/models/collection.rs b/src/models/collection.rs index 5dcefb8..715c303 100644 --- a/src/models/collection.rs +++ b/src/models/collection.rs @@ -108,7 +108,6 @@ impl Collection { pub fn bytes_used(&self) -> &i64 { &self.bytes_used } - } #[cfg(test)] diff --git a/src/models/collection_list.rs b/src/models/collection_list.rs index a7dbff7..97983c6 100644 --- a/src/models/collection_list.rs +++ b/src/models/collection_list.rs @@ -24,7 +24,6 @@ impl CollectionList { pub fn collections(&self) -> &Vec { &self.collections } - } #[cfg(test)] diff --git a/src/models/column_bigint.rs b/src/models/column_bigint.rs index dfe6bbe..1228086 100644 --- a/src/models/column_bigint.rs +++ b/src/models/column_bigint.rs @@ -127,7 +127,6 @@ impl ColumnBigint { pub fn default(&self) -> Option<&i64> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_boolean.rs b/src/models/column_boolean.rs index 8ddb729..65aa9af 100644 --- a/src/models/column_boolean.rs +++ b/src/models/column_boolean.rs @@ -97,7 +97,6 @@ impl ColumnBoolean { pub fn default(&self) -> Option<&bool> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_datetime.rs b/src/models/column_datetime.rs index fcda790..a172665 100644 --- a/src/models/column_datetime.rs +++ b/src/models/column_datetime.rs @@ -104,7 +104,6 @@ impl ColumnDatetime { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_email.rs b/src/models/column_email.rs index b2b8c50..f1c1037 100644 --- a/src/models/column_email.rs +++ b/src/models/column_email.rs @@ -105,7 +105,6 @@ impl ColumnEmail { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_enum.rs b/src/models/column_enum.rs index cb9e825..d9b6b4f 100644 --- a/src/models/column_enum.rs +++ b/src/models/column_enum.rs @@ -113,7 +113,6 @@ impl ColumnEnum { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_float.rs b/src/models/column_float.rs index 1074251..865bd38 100644 --- a/src/models/column_float.rs +++ b/src/models/column_float.rs @@ -127,7 +127,6 @@ impl ColumnFloat { pub fn default(&self) -> Option<&f64> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_index.rs b/src/models/column_index.rs index 09961f0..7e2a97b 100644 --- a/src/models/column_index.rs +++ b/src/models/column_index.rs @@ -97,7 +97,6 @@ impl ColumnIndex { pub fn orders(&self) -> Option<&Vec> { self.orders.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_index_list.rs b/src/models/column_index_list.rs index 815f606..2ea7645 100644 --- a/src/models/column_index_list.rs +++ b/src/models/column_index_list.rs @@ -24,7 +24,6 @@ impl ColumnIndexList { pub fn indexes(&self) -> &Vec { &self.indexes } - } #[cfg(test)] diff --git a/src/models/column_integer.rs b/src/models/column_integer.rs index f50fdf0..8a6cd9e 100644 --- a/src/models/column_integer.rs +++ b/src/models/column_integer.rs @@ -127,7 +127,6 @@ impl ColumnInteger { pub fn default(&self) -> Option<&i64> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_ip.rs b/src/models/column_ip.rs index 17130c9..a94cf00 100644 --- a/src/models/column_ip.rs +++ b/src/models/column_ip.rs @@ -105,7 +105,6 @@ impl ColumnIp { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_line.rs b/src/models/column_line.rs index 3523ffd..01d2239 100644 --- a/src/models/column_line.rs +++ b/src/models/column_line.rs @@ -97,7 +97,6 @@ impl ColumnLine { pub fn default(&self) -> Option<&Vec>> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_list.rs b/src/models/column_list.rs index 921ac76..aaa362b 100644 --- a/src/models/column_list.rs +++ b/src/models/column_list.rs @@ -24,7 +24,6 @@ impl ColumnList { pub fn columns(&self) -> &Vec { &self.columns } - } #[cfg(test)] diff --git a/src/models/column_longtext.rs b/src/models/column_longtext.rs index 4f4cc68..6d418d9 100644 --- a/src/models/column_longtext.rs +++ b/src/models/column_longtext.rs @@ -112,7 +112,6 @@ impl ColumnLongtext { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_mediumtext.rs b/src/models/column_mediumtext.rs index 905b798..90b3d33 100644 --- a/src/models/column_mediumtext.rs +++ b/src/models/column_mediumtext.rs @@ -112,7 +112,6 @@ impl ColumnMediumtext { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_point.rs b/src/models/column_point.rs index 4d49b0b..6d402ea 100644 --- a/src/models/column_point.rs +++ b/src/models/column_point.rs @@ -97,7 +97,6 @@ impl ColumnPoint { pub fn default(&self) -> Option<&Vec> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_polygon.rs b/src/models/column_polygon.rs index 2a12e83..d0afe7e 100644 --- a/src/models/column_polygon.rs +++ b/src/models/column_polygon.rs @@ -97,7 +97,6 @@ impl ColumnPolygon { pub fn default(&self) -> Option<&Vec>>> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_relationship.rs b/src/models/column_relationship.rs index 7281849..441476a 100644 --- a/src/models/column_relationship.rs +++ b/src/models/column_relationship.rs @@ -129,7 +129,6 @@ impl ColumnRelationship { pub fn side(&self) -> &String { &self.side } - } #[cfg(test)] diff --git a/src/models/column_string.rs b/src/models/column_string.rs index 77c0844..c7128c3 100644 --- a/src/models/column_string.rs +++ b/src/models/column_string.rs @@ -120,7 +120,6 @@ impl ColumnString { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_text.rs b/src/models/column_text.rs index bb65f36..0ad76c5 100644 --- a/src/models/column_text.rs +++ b/src/models/column_text.rs @@ -112,7 +112,6 @@ impl ColumnText { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_url.rs b/src/models/column_url.rs index 9dbf22e..b509d2f 100644 --- a/src/models/column_url.rs +++ b/src/models/column_url.rs @@ -105,7 +105,6 @@ impl ColumnUrl { pub fn default(&self) -> Option<&String> { self.default.as_ref() } - } #[cfg(test)] diff --git a/src/models/column_varchar.rs b/src/models/column_varchar.rs index 2e4e2b9..e163c87 100644 --- a/src/models/column_varchar.rs +++ b/src/models/column_varchar.rs @@ -120,7 +120,6 @@ impl ColumnVarchar { pub fn encrypt(&self) -> Option<&bool> { self.encrypt.as_ref() } - } #[cfg(test)] diff --git a/src/models/continent.rs b/src/models/continent.rs index 3c6606e..c13199c 100644 --- a/src/models/continent.rs +++ b/src/models/continent.rs @@ -24,7 +24,6 @@ impl Continent { pub fn code(&self) -> &String { &self.code } - } #[cfg(test)] diff --git a/src/models/continent_list.rs b/src/models/continent_list.rs index 0dd6abe..2490dbd 100644 --- a/src/models/continent_list.rs +++ b/src/models/continent_list.rs @@ -24,7 +24,6 @@ impl ContinentList { pub fn continents(&self) -> &Vec { &self.continents } - } #[cfg(test)] diff --git a/src/models/country.rs b/src/models/country.rs index dd91dd6..bf48f60 100644 --- a/src/models/country.rs +++ b/src/models/country.rs @@ -24,7 +24,6 @@ impl Country { pub fn code(&self) -> &String { &self.code } - } #[cfg(test)] diff --git a/src/models/country_list.rs b/src/models/country_list.rs index e056c22..bf4eeb1 100644 --- a/src/models/country_list.rs +++ b/src/models/country_list.rs @@ -24,7 +24,6 @@ impl CountryList { pub fn countries(&self) -> &Vec { &self.countries } - } #[cfg(test)] diff --git a/src/models/currency.rs b/src/models/currency.rs index 0418f97..9d45fe6 100644 --- a/src/models/currency.rs +++ b/src/models/currency.rs @@ -65,7 +65,6 @@ impl Currency { pub fn name_plural(&self) -> &String { &self.name_plural } - } #[cfg(test)] diff --git a/src/models/currency_list.rs b/src/models/currency_list.rs index 5ba2a2f..86fa828 100644 --- a/src/models/currency_list.rs +++ b/src/models/currency_list.rs @@ -24,7 +24,6 @@ impl CurrencyList { pub fn currencies(&self) -> &Vec { &self.currencies } - } #[cfg(test)] diff --git a/src/models/database.rs b/src/models/database.rs index 3677330..5c0a45d 100644 --- a/src/models/database.rs +++ b/src/models/database.rs @@ -48,6 +48,22 @@ pub struct Database { #[serde(rename = "replicas")] #[serde(skip_serializing_if = "Option::is_none")] pub replicas: Option, + /// Error message when the dedicated backing failed. Null when the database has + /// no dedicated backing or has not failed. + #[serde(rename = "error")] + #[serde(skip_serializing_if = "Option::is_none")] + pub error: Option, + /// Container status of the dedicated backing: active or inactive. Null when + /// the database has no dedicated backing or the runtime has not reported one. + #[serde(rename = "containerStatus")] + #[serde(skip_serializing_if = "Option::is_none")] + pub container_status: Option, + /// Idle-lifecycle state of the dedicated backing: active, warm, cold, or + /// hibernated. Null when the database has no dedicated backing or the runtime + /// has not reported one. + #[serde(rename = "lifecycleState")] + #[serde(skip_serializing_if = "Option::is_none")] + pub lifecycle_state: Option, /// Database backup policies. #[serde(rename = "policies")] #[serde(skip_serializing_if = "Option::is_none")] @@ -133,6 +149,39 @@ impl Database { self.replicas.as_ref() } + /// Set error + pub fn set_error(mut self, error: String) -> Self { + self.error = Some(error); + self + } + + /// Get error + pub fn error(&self) -> Option<&String> { + self.error.as_ref() + } + + /// Set container_status + pub fn set_container_status(mut self, container_status: String) -> Self { + self.container_status = Some(container_status); + self + } + + /// Get container_status + pub fn container_status(&self) -> Option<&String> { + self.container_status.as_ref() + } + + /// Set lifecycle_state + pub fn set_lifecycle_state(mut self, lifecycle_state: String) -> Self { + self.lifecycle_state = Some(lifecycle_state); + self + } + + /// Get lifecycle_state + pub fn lifecycle_state(&self) -> Option<&String> { + self.lifecycle_state.as_ref() + } + /// Set policies pub fn set_policies(mut self, policies: Vec) -> Self { self.policies = Some(policies); @@ -154,7 +203,6 @@ impl Database { pub fn archives(&self) -> Option<&Vec> { self.archives.as_ref() } - } #[cfg(test)] diff --git a/src/models/database_list.rs b/src/models/database_list.rs index d7f6614..78fe039 100644 --- a/src/models/database_list.rs +++ b/src/models/database_list.rs @@ -24,7 +24,6 @@ impl DatabaseList { pub fn databases(&self) -> &Vec { &self.databases } - } #[cfg(test)] diff --git a/src/models/database_migration.rs b/src/models/database_migration.rs index a150440..0a05aa6 100644 --- a/src/models/database_migration.rs +++ b/src/models/database_migration.rs @@ -38,6 +38,9 @@ pub struct DatabaseMigration { /// Number of documents still pending replication to the target. #[serde(rename = "lagDocuments")] pub lag_documents: i64, + /// Highest source changelog sequence applied to the target so far. + #[serde(rename = "changelogWatermark")] + pub changelog_watermark: i64, /// Time the migrated data was verified against the source in ISO 8601 format. #[serde(rename = "verifiedAt")] pub verified_at: String, @@ -113,6 +116,11 @@ impl DatabaseMigration { &self.lag_documents } + /// Get changelog_watermark + pub fn changelog_watermark(&self) -> &i64 { + &self.changelog_watermark + } + /// Get verified_at pub fn verified_at(&self) -> &String { &self.verified_at @@ -142,7 +150,6 @@ impl DatabaseMigration { pub fn paused(&self) -> &bool { &self.paused } - } #[cfg(test)] @@ -162,6 +169,7 @@ mod tests { let _ = _model.attempt(); let _ = _model.last_error(); let _ = _model.lag_documents(); + let _ = _model.changelog_watermark(); let _ = _model.verified_at(); let _ = _model.cutover_at(); let _ = _model.soak_until(); diff --git a/src/models/database_migration_list.rs b/src/models/database_migration_list.rs index f6d7af0..ad8e45f 100644 --- a/src/models/database_migration_list.rs +++ b/src/models/database_migration_list.rs @@ -24,7 +24,6 @@ impl DatabaseMigrationList { pub fn migrations(&self) -> &Vec { &self.migrations } - } #[cfg(test)] diff --git a/src/models/database_status.rs b/src/models/database_status.rs index 6a4cf33..d0b0403 100644 --- a/src/models/database_status.rs +++ b/src/models/database_status.rs @@ -150,7 +150,6 @@ impl DatabaseStatus { pub fn volumes(&self) -> &Vec { &self.volumes } - } #[cfg(test)] diff --git a/src/models/database_status_connections.rs b/src/models/database_status_connections.rs index f80c633..0e7652d 100644 --- a/src/models/database_status_connections.rs +++ b/src/models/database_status_connections.rs @@ -26,7 +26,6 @@ impl DatabaseStatusConnections { pub fn max(&self) -> &i64 { &self.max } - } #[cfg(test)] @@ -46,7 +45,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/database_status_replica.rs b/src/models/database_status_replica.rs index 8d1686e..f182cdb 100644 --- a/src/models/database_status_replica.rs +++ b/src/models/database_status_replica.rs @@ -19,7 +19,17 @@ pub struct DatabaseStatusReplica { /// Whether the replica is healthy. #[serde(rename = "healthy")] pub healthy: bool, - /// Replication lag in seconds (null for primary). + /// Whether the engine reports this member's replication stream as up. Null + /// when no reading was taken: a primary has no stream to report, and a member + /// that is not healthy, or whose probe did not answer, has none yet. `healthy` + /// is a reachability probe of the member itself and says nothing about + /// replication, so a healthy member may still not be replicating. + #[serde(rename = "replicating")] + #[serde(skip_serializing_if = "Option::is_none")] + pub replicating: Option, + /// Replication lag in seconds (null for primary). Also null against + /// `replicating: true`, for a member that is streaming but whose engine + /// printed no numeric lag. #[serde(rename = "lagSeconds")] #[serde(skip_serializing_if = "Option::is_none")] pub lag_seconds: Option, @@ -41,6 +51,17 @@ impl DatabaseStatusReplica { &self.healthy } + /// Set replicating + pub fn set_replicating(mut self, replicating: bool) -> Self { + self.replicating = Some(replicating); + self + } + + /// Get replicating + pub fn replicating(&self) -> Option<&bool> { + self.replicating.as_ref() + } + /// Set lag_seconds pub fn set_lag_seconds(mut self, lag_seconds: f64) -> Self { self.lag_seconds = Some(lag_seconds); @@ -51,7 +72,6 @@ impl DatabaseStatusReplica { pub fn lag_seconds(&self) -> Option<&f64> { self.lag_seconds.as_ref() } - } #[cfg(test)] diff --git a/src/models/database_status_volume.rs b/src/models/database_status_volume.rs index b4e4955..35ea096 100644 --- a/src/models/database_status_volume.rs +++ b/src/models/database_status_volume.rs @@ -40,7 +40,6 @@ impl DatabaseStatusVolume { pub fn mounted(&self) -> &bool { &self.mounted } - } #[cfg(test)] diff --git a/src/models/dedicated_database.rs b/src/models/dedicated_database.rs index 3ba5fdb..eee3fde 100644 --- a/src/models/dedicated_database.rs +++ b/src/models/dedicated_database.rs @@ -426,7 +426,6 @@ impl DedicatedDatabase { pub fn error(&self) -> &String { &self.error } - } #[cfg(test)] diff --git a/src/models/dedicated_database_backup.rs b/src/models/dedicated_database_backup.rs new file mode 100644 index 0000000..703d3d6 --- /dev/null +++ b/src/models/dedicated_database_backup.rs @@ -0,0 +1,226 @@ +//! DedicatedDatabaseBackup model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Backup +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseBackup { + /// Backup ID. + #[serde(rename = "$id")] + pub id: String, + /// Backup creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + pub created_at: String, + /// Database ID this backup belongs to. + #[serde(rename = "databaseId")] + pub database_id: String, + /// Project ID. + #[serde(rename = "projectId")] + pub project_id: String, + /// Backup policy ID when the backup was created by a schedule. + #[serde(rename = "policyId")] + pub policy_id: String, + /// Backup trigger. Possible values: manual, schedule. + #[serde(rename = "trigger")] + pub trigger: String, + /// Backup type. Possible values: full (complete database snapshot), + /// incremental (changes since last backup), wal (write-ahead log continuous + /// archival). + #[serde(rename = "type")] + pub r#type: String, + /// Backup type that was requested. Differs from `type` when the backend could + /// not run the requested type and took a different one instead, in which case + /// `fallbackReason` explains why. Empty for backups taken before the requested + /// type was recorded. + #[serde(rename = "requestedType")] + pub requested_type: String, + /// Why the backend ran a different backup type than the one requested. Empty + /// when the backup ran as requested. + #[serde(rename = "fallbackReason")] + pub fallback_reason: String, + /// Backup status. Possible values: pending (queued for processing), running + /// (currently in progress), completed (successfully finished), failed + /// (encountered an error), verified (integrity check passed). + #[serde(rename = "status")] + pub status: String, + /// Backup size in bytes. + #[serde(rename = "sizeBytes")] + pub size_bytes: i64, + /// Backup start time in ISO 8601 format. + #[serde(rename = "startedAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub started_at: Option, + /// Backup completion time in ISO 8601 format. + #[serde(rename = "completedAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub completed_at: Option, + /// Backup verification time in ISO 8601 format. + #[serde(rename = "verifiedAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub verified_at: Option, + /// Backup expiration time in ISO 8601 format. + #[serde(rename = "expiresAt")] + #[serde(skip_serializing_if = "Option::is_none")] + pub expires_at: Option, + /// Transaction-log position the backup anchors at, in the engine's own + /// notation: PostgreSQL `{walSegment}|{lsn}`, MySQL and MariaDB + /// `{binlogFile}|{offset}`, MongoDB `{seconds}|{increment}`. Empty when the + /// backup recorded no position, which is the case for backup types that carry + /// none. + #[serde(rename = "logPosition")] + #[serde(skip_serializing_if = "Option::is_none")] + pub log_position: Option, + /// Error message if backup failed. + #[serde(rename = "error")] + pub error: String, +} + +impl DedicatedDatabaseBackup { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get created_at + pub fn created_at(&self) -> &String { + &self.created_at + } + + /// Get database_id + pub fn database_id(&self) -> &String { + &self.database_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get policy_id + pub fn policy_id(&self) -> &String { + &self.policy_id + } + + /// Get trigger + pub fn trigger(&self) -> &String { + &self.trigger + } + + /// Get r#type + pub fn r#type(&self) -> &String { + &self.r#type + } + + /// Get requested_type + pub fn requested_type(&self) -> &String { + &self.requested_type + } + + /// Get fallback_reason + pub fn fallback_reason(&self) -> &String { + &self.fallback_reason + } + + /// Get status + pub fn status(&self) -> &String { + &self.status + } + + /// Get size_bytes + pub fn size_bytes(&self) -> &i64 { + &self.size_bytes + } + + /// Set started_at + pub fn set_started_at(mut self, started_at: String) -> Self { + self.started_at = Some(started_at); + self + } + + /// Get started_at + pub fn started_at(&self) -> Option<&String> { + self.started_at.as_ref() + } + + /// Set completed_at + pub fn set_completed_at(mut self, completed_at: String) -> Self { + self.completed_at = Some(completed_at); + self + } + + /// Get completed_at + pub fn completed_at(&self) -> Option<&String> { + self.completed_at.as_ref() + } + + /// Set verified_at + pub fn set_verified_at(mut self, verified_at: String) -> Self { + self.verified_at = Some(verified_at); + self + } + + /// Get verified_at + pub fn verified_at(&self) -> Option<&String> { + self.verified_at.as_ref() + } + + /// Set expires_at + pub fn set_expires_at(mut self, expires_at: String) -> Self { + self.expires_at = Some(expires_at); + self + } + + /// Get expires_at + pub fn expires_at(&self) -> Option<&String> { + self.expires_at.as_ref() + } + + /// Set log_position + pub fn set_log_position(mut self, log_position: String) -> Self { + self.log_position = Some(log_position); + self + } + + /// Get log_position + pub fn log_position(&self) -> Option<&String> { + self.log_position.as_ref() + } + + /// Get error + pub fn error(&self) -> &String { + &self.error + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_backup_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.database_id(); + let _ = _model.project_id(); + let _ = _model.policy_id(); + let _ = _model.trigger(); + let _ = _model.r#type(); + let _ = _model.requested_type(); + let _ = _model.fallback_reason(); + let _ = _model.status(); + let _ = _model.size_bytes(); + let _ = _model.error(); + } + + #[test] + fn test_dedicated_database_backup_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/dedicated_database_backup_list.rs b/src/models/dedicated_database_backup_list.rs new file mode 100644 index 0000000..4833b14 --- /dev/null +++ b/src/models/dedicated_database_backup_list.rs @@ -0,0 +1,50 @@ +//! DedicatedDatabaseBackupList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// BackupList +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseBackupList { + /// Total number of backups. + #[serde(rename = "total")] + pub total: i64, + /// List of backups. + #[serde(rename = "backups")] + pub backups: Vec, +} + +impl DedicatedDatabaseBackupList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get backups + pub fn backups(&self) -> &Vec { + &self.backups + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_backup_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.backups(); + } + + #[test] + fn test_dedicated_database_backup_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/dedicated_database_backup_storage.rs b/src/models/dedicated_database_backup_storage.rs new file mode 100644 index 0000000..395e376 --- /dev/null +++ b/src/models/dedicated_database_backup_storage.rs @@ -0,0 +1,78 @@ +//! DedicatedDatabaseBackupStorage model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// BackupStorageConfig +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseBackupStorage { + /// Storage provider. Possible values: s3 (Amazon S3 or S3-compatible), gcs + /// (Google Cloud Storage), azure (Azure Blob Storage). + #[serde(rename = "provider")] + pub provider: String, + /// Storage bucket or container name. + #[serde(rename = "bucket")] + pub bucket: String, + /// Storage region. + #[serde(rename = "region")] + pub region: String, + /// Object key prefix for backups. + #[serde(rename = "prefix")] + pub prefix: String, + /// Custom endpoint for S3-compatible storage. + #[serde(rename = "endpoint")] + pub endpoint: String, +} + +impl DedicatedDatabaseBackupStorage { + /// Get provider + pub fn provider(&self) -> &String { + &self.provider + } + + /// Get bucket + pub fn bucket(&self) -> &String { + &self.bucket + } + + /// Get region + pub fn region(&self) -> &String { + &self.region + } + + /// Get prefix + pub fn prefix(&self) -> &String { + &self.prefix + } + + /// Get endpoint + pub fn endpoint(&self) -> &String { + &self.endpoint + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_backup_storage_creation() { + let _model = ::default(); + let _ = _model.provider(); + let _ = _model.bucket(); + let _ = _model.region(); + let _ = _model.prefix(); + let _ = _model.endpoint(); + } + + #[test] + fn test_dedicated_database_backup_storage_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/dedicated_database_branch.rs b/src/models/dedicated_database_branch.rs new file mode 100644 index 0000000..db3bc19 --- /dev/null +++ b/src/models/dedicated_database_branch.rs @@ -0,0 +1,140 @@ +//! DedicatedDatabaseBranch model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Branch +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseBranch { + /// Branch identifier. + #[serde(rename = "branchId")] + pub branch_id: String, + /// Branch name. + #[serde(rename = "branchName")] + pub branch_name: String, + /// Kubernetes namespace where the branch is deployed. + #[serde(rename = "namespace")] + pub namespace: String, + /// Unix timestamp when the branch expires. + #[serde(rename = "expiresAt")] + pub expires_at: i64, + /// Branch hostname for direct connections. + #[serde(rename = "host")] + pub host: String, + /// Branch port. Null until the backing reports one. + #[serde(rename = "port")] + pub port: i64, + /// Advertised catalog the client connects to. MySQL/MariaDB use default; + /// Postgres uses the routing label. + #[serde(rename = "database")] + pub database: String, + /// Database username. Shared with the parent database. + #[serde(rename = "username")] + pub username: String, + /// Database password. Shared with the parent database. + #[serde(rename = "password")] + pub password: String, + /// Whether SSL is required. + #[serde(rename = "ssl")] + pub ssl: bool, + /// Database engine. Possible values: postgresql, mysql, mongodb. + #[serde(rename = "engine")] + pub engine: String, + /// Full connection string for the branch. + #[serde(rename = "connectionString")] + pub connection_string: String, +} + +impl DedicatedDatabaseBranch { + /// Get branch_id + pub fn branch_id(&self) -> &String { + &self.branch_id + } + + /// Get branch_name + pub fn branch_name(&self) -> &String { + &self.branch_name + } + + /// Get namespace + pub fn namespace(&self) -> &String { + &self.namespace + } + + /// Get expires_at + pub fn expires_at(&self) -> &i64 { + &self.expires_at + } + + /// Get host + pub fn host(&self) -> &String { + &self.host + } + + /// Get port + pub fn port(&self) -> &i64 { + &self.port + } + + /// Get database + pub fn database(&self) -> &String { + &self.database + } + + /// Get username + pub fn username(&self) -> &String { + &self.username + } + + /// Get password + pub fn password(&self) -> &String { + &self.password + } + + /// Get ssl + pub fn ssl(&self) -> &bool { + &self.ssl + } + + /// Get engine + pub fn engine(&self) -> &String { + &self.engine + } + + /// Get connection_string + pub fn connection_string(&self) -> &String { + &self.connection_string + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_branch_creation() { + let _model = ::default(); + let _ = _model.branch_id(); + let _ = _model.branch_name(); + let _ = _model.namespace(); + let _ = _model.expires_at(); + let _ = _model.host(); + let _ = _model.port(); + let _ = _model.database(); + let _ = _model.username(); + let _ = _model.password(); + let _ = _model.ssl(); + let _ = _model.engine(); + let _ = _model.connection_string(); + } + + #[test] + fn test_dedicated_database_branch_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/dedicated_database_branch_list.rs b/src/models/dedicated_database_branch_list.rs new file mode 100644 index 0000000..50da757 --- /dev/null +++ b/src/models/dedicated_database_branch_list.rs @@ -0,0 +1,50 @@ +//! DedicatedDatabaseBranchList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// BranchList +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseBranchList { + /// Total number of branches. + #[serde(rename = "total")] + pub total: i64, + /// List of branches. + #[serde(rename = "branches")] + pub branches: Vec, +} + +impl DedicatedDatabaseBranchList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get branches + pub fn branches(&self) -> &Vec { + &self.branches + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_branch_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.branches(); + } + + #[test] + fn test_dedicated_database_branch_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/dedicated_database_execution.rs b/src/models/dedicated_database_execution.rs new file mode 100644 index 0000000..cbd430a --- /dev/null +++ b/src/models/dedicated_database_execution.rs @@ -0,0 +1,89 @@ +//! DedicatedDatabaseExecution model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Execution +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseExecution { + /// Result rows as a list of column-name => value maps. Empty for non-returning + /// statements. + #[serde(rename = "rows")] + pub rows: Vec, + /// Number of rows returned (for SELECT) or affected (for + /// INSERT/UPDATE/DELETE). + #[serde(rename = "rowCount")] + pub row_count: i64, + /// Column metadata in result-set order. + #[serde(rename = "columns")] + pub columns: Vec, + /// Server-side execution time in milliseconds. + #[serde(rename = "durationMs")] + pub duration_ms: i64, + /// True when the configured row or byte cap was hit and the result was + /// truncated. + #[serde(rename = "truncated")] + pub truncated: bool, + /// Serialised payload size in bytes. + #[serde(rename = "bytes")] + pub bytes: i64, +} + +impl DedicatedDatabaseExecution { + /// Get rows + pub fn rows(&self) -> &Vec { + &self.rows + } + + /// Get row_count + pub fn row_count(&self) -> &i64 { + &self.row_count + } + + /// Get columns + pub fn columns(&self) -> &Vec { + &self.columns + } + + /// Get duration_ms + pub fn duration_ms(&self) -> &i64 { + &self.duration_ms + } + + /// Get truncated + pub fn truncated(&self) -> &bool { + &self.truncated + } + + /// Get bytes + pub fn bytes(&self) -> &i64 { + &self.bytes + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_execution_creation() { + let _model = ::default(); + let _ = _model.rows(); + let _ = _model.row_count(); + let _ = _model.columns(); + let _ = _model.duration_ms(); + let _ = _model.truncated(); + let _ = _model.bytes(); + } + + #[test] + fn test_dedicated_database_execution_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/dedicated_database_execution_column.rs b/src/models/dedicated_database_execution_column.rs new file mode 100644 index 0000000..0ec270d --- /dev/null +++ b/src/models/dedicated_database_execution_column.rs @@ -0,0 +1,50 @@ +//! DedicatedDatabaseExecutionColumn model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// ExecutionColumn +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseExecutionColumn { + /// Column name as returned by the database. + #[serde(rename = "name")] + pub name: String, + /// Engine-specific column type (e.g. int4, text, timestamptz). + #[serde(rename = "type")] + pub r#type: String, +} + +impl DedicatedDatabaseExecutionColumn { + /// Get name + pub fn name(&self) -> &String { + &self.name + } + + /// Get r#type + pub fn r#type(&self) -> &String { + &self.r#type + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_execution_column_creation() { + let _model = ::default(); + let _ = _model.name(); + let _ = _model.r#type(); + } + + #[test] + fn test_dedicated_database_execution_column_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/dedicated_database_extensions.rs b/src/models/dedicated_database_extensions.rs new file mode 100644 index 0000000..eefa389 --- /dev/null +++ b/src/models/dedicated_database_extensions.rs @@ -0,0 +1,60 @@ +//! DedicatedDatabaseExtensions model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Extensions +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseExtensions { + /// List of installed extensions. + #[serde(rename = "installed")] + pub installed: Vec, + /// List of available extensions that can be installed. + #[serde(rename = "available")] + pub available: Vec, + /// Curated metadata (display name, description, category) for each available + /// extension. + #[serde(rename = "metadata")] + pub metadata: Vec, +} + +impl DedicatedDatabaseExtensions { + /// Get installed + pub fn installed(&self) -> &Vec { + &self.installed + } + + /// Get available + pub fn available(&self) -> &Vec { + &self.available + } + + /// Get metadata + pub fn metadata(&self) -> &Vec { + &self.metadata + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_extensions_creation() { + let _model = ::default(); + let _ = _model.installed(); + let _ = _model.available(); + let _ = _model.metadata(); + } + + #[test] + fn test_dedicated_database_extensions_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/dedicated_database_list.rs b/src/models/dedicated_database_list.rs new file mode 100644 index 0000000..7c68b07 --- /dev/null +++ b/src/models/dedicated_database_list.rs @@ -0,0 +1,49 @@ +//! DedicatedDatabaseList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Dedicated databases list +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseList { + /// Total number of databases that matched your query. + #[serde(rename = "total")] + pub total: i64, + /// List of databases. + #[serde(rename = "databases")] + pub databases: Vec, +} + +impl DedicatedDatabaseList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get databases + pub fn databases(&self) -> &Vec { + &self.databases + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.databases(); + } + + #[test] + fn test_dedicated_database_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/dedicated_database_member.rs b/src/models/dedicated_database_member.rs index 2c9a06d..df7f0d1 100644 --- a/src/models/dedicated_database_member.rs +++ b/src/models/dedicated_database_member.rs @@ -22,8 +22,20 @@ pub struct DedicatedDatabaseMember { /// phase reported by the cluster. #[serde(rename = "status")] pub status: String, + /// Whether the engine reports this member's replication stream as up. Null + /// when no reading was taken: a primary has no stream to report, and a member + /// that is not active, or whose probe did not answer, has none yet. False is a + /// reading and null is the absence of one, so the two are not interchangeable. + /// Read it beside lagSeconds before expecting a failover that names no target + /// to find a promotable standby: a member streaming at a known lag is one, and + /// a member reporting null is not evidence either way. + #[serde(rename = "replicating")] + #[serde(skip_serializing_if = "Option::is_none")] + pub replicating: Option, /// Replication lag in seconds. Null when the lag is not known: a primary has - /// none to report, and a member the backend has not probed has none yet. + /// none to report, and a member the backend has not probed has none yet. Also + /// null against `replicating: true`, for a member that is streaming but whose + /// engine printed no numeric lag. #[serde(rename = "lagSeconds")] #[serde(skip_serializing_if = "Option::is_none")] pub lag_seconds: Option, @@ -45,6 +57,17 @@ impl DedicatedDatabaseMember { &self.status } + /// Set replicating + pub fn set_replicating(mut self, replicating: bool) -> Self { + self.replicating = Some(replicating); + self + } + + /// Get replicating + pub fn replicating(&self) -> Option<&bool> { + self.replicating.as_ref() + } + /// Set lag_seconds pub fn set_lag_seconds(mut self, lag_seconds: f64) -> Self { self.lag_seconds = Some(lag_seconds); @@ -55,7 +78,6 @@ impl DedicatedDatabaseMember { pub fn lag_seconds(&self) -> Option<&f64> { self.lag_seconds.as_ref() } - } #[cfg(test)] diff --git a/src/models/dedicated_database_operation.rs b/src/models/dedicated_database_operation.rs index 668bac5..d63f28a 100644 --- a/src/models/dedicated_database_operation.rs +++ b/src/models/dedicated_database_operation.rs @@ -19,8 +19,9 @@ pub struct DedicatedDatabaseOperation { /// failover, backup-create or cross-region-enable. #[serde(rename = "type")] pub r#type: String, - /// Operation status. Possible values: running (in progress), completed - /// (finished successfully), failed (ended in an error). + /// Operation status. Possible values: queued (accepted and waiting to resume), + /// running (in progress), completed (finished successfully), failed (ended in + /// an error). #[serde(rename = "status")] pub status: String, /// Number of times this operation has been attempted. @@ -120,7 +121,6 @@ impl DedicatedDatabaseOperation { pub fn error_message(&self) -> &String { &self.error_message } - } #[cfg(test)] @@ -146,7 +146,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/dedicated_database_operation_list.rs b/src/models/dedicated_database_operation_list.rs index 1e22e87..641721c 100644 --- a/src/models/dedicated_database_operation_list.rs +++ b/src/models/dedicated_database_operation_list.rs @@ -24,7 +24,6 @@ impl DedicatedDatabaseOperationList { pub fn operations(&self) -> &Vec { &self.operations } - } #[cfg(test)] @@ -44,7 +43,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/dedicated_database_pitr_windows.rs b/src/models/dedicated_database_pitr_windows.rs new file mode 100644 index 0000000..52b2fe5 --- /dev/null +++ b/src/models/dedicated_database_pitr_windows.rs @@ -0,0 +1,50 @@ +//! DedicatedDatabasePITRWindows model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// PITRWindows +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabasePITRWindows { + /// Earliest available recovery point. + #[serde(rename = "earliest")] + pub earliest: String, + /// Latest available recovery point. + #[serde(rename = "latest")] + pub latest: String, +} + +impl DedicatedDatabasePITRWindows { + /// Get earliest + pub fn earliest(&self) -> &String { + &self.earliest + } + + /// Get latest + pub fn latest(&self) -> &String { + &self.latest + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_pitr_windows_creation() { + let _model = ::default(); + let _ = _model.earliest(); + let _ = _model.latest(); + } + + #[test] + fn test_dedicated_database_pitr_windows_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/dedicated_database_pooler.rs b/src/models/dedicated_database_pooler.rs new file mode 100644 index 0000000..d1fa674 --- /dev/null +++ b/src/models/dedicated_database_pooler.rs @@ -0,0 +1,134 @@ +//! DedicatedDatabasePooler model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// PoolerConfig +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabasePooler { + /// Whether connection pooling is enabled. + #[serde(rename = "enabled")] + pub enabled: bool, + /// Connection pool mode. Possible values: transaction (releases connections + /// back to pool after each transaction), session (holds connections for the + /// entire client session). + #[serde(rename = "mode")] + pub mode: String, + /// Client-connection ceiling the pooler accepts. Enforced on MySQL and + /// MariaDB; on PostgreSQL the pooler has no client cap, so this reports the + /// database's advertised networkMaxConnections and cannot be set here. + #[serde(rename = "maxConnections")] + pub max_connections: i64, + /// Default pool size per user. + #[serde(rename = "defaultPoolSize")] + pub default_pool_size: i64, + /// Pooler listening port. + #[serde(rename = "port")] + pub port: i64, + /// Whether SELECTs are routed to HA replicas while writes and locked reads + /// stay on the primary. Active only when HA is enabled. + #[serde(rename = "readWriteSplitting")] + pub read_write_splitting: bool, + /// Effective CPU request applied to the pooler sidecar container (Kubernetes + /// quantity). Returns the proportional default (5% of DB CPU, floor 100m) + /// unless overridden. + #[serde(rename = "poolerCpuRequest")] + pub pooler_cpu_request: String, + /// Effective CPU limit applied to the pooler sidecar container (Kubernetes + /// quantity). Returns the proportional default (10% of DB CPU, floor 200m) + /// unless overridden. + #[serde(rename = "poolerCpuLimit")] + pub pooler_cpu_limit: String, + /// Effective memory request applied to the pooler sidecar container + /// (Kubernetes quantity). Returns the proportional default (7.5% of DB memory, + /// floor 64Mi) unless overridden. + #[serde(rename = "poolerMemoryRequest")] + pub pooler_memory_request: String, + /// Effective memory limit applied to the pooler sidecar container (Kubernetes + /// quantity). Returns the proportional default (15% of DB memory, floor 128Mi) + /// unless overridden. + #[serde(rename = "poolerMemoryLimit")] + pub pooler_memory_limit: String, +} + +impl DedicatedDatabasePooler { + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get mode + pub fn mode(&self) -> &String { + &self.mode + } + + /// Get max_connections + pub fn max_connections(&self) -> &i64 { + &self.max_connections + } + + /// Get default_pool_size + pub fn default_pool_size(&self) -> &i64 { + &self.default_pool_size + } + + /// Get port + pub fn port(&self) -> &i64 { + &self.port + } + + /// Get read_write_splitting + pub fn read_write_splitting(&self) -> &bool { + &self.read_write_splitting + } + + /// Get pooler_cpu_request + pub fn pooler_cpu_request(&self) -> &String { + &self.pooler_cpu_request + } + + /// Get pooler_cpu_limit + pub fn pooler_cpu_limit(&self) -> &String { + &self.pooler_cpu_limit + } + + /// Get pooler_memory_request + pub fn pooler_memory_request(&self) -> &String { + &self.pooler_memory_request + } + + /// Get pooler_memory_limit + pub fn pooler_memory_limit(&self) -> &String { + &self.pooler_memory_limit + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_pooler_creation() { + let _model = ::default(); + let _ = _model.enabled(); + let _ = _model.mode(); + let _ = _model.max_connections(); + let _ = _model.default_pool_size(); + let _ = _model.port(); + let _ = _model.read_write_splitting(); + let _ = _model.pooler_cpu_request(); + let _ = _model.pooler_cpu_limit(); + let _ = _model.pooler_memory_request(); + let _ = _model.pooler_memory_limit(); + } + + #[test] + fn test_dedicated_database_pooler_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/dedicated_database_replicas.rs b/src/models/dedicated_database_replicas.rs index bf4eaca..24bd468 100644 --- a/src/models/dedicated_database_replicas.rs +++ b/src/models/dedicated_database_replicas.rs @@ -103,7 +103,6 @@ impl DedicatedDatabaseReplicas { pub fn members(&self) -> &Vec { &self.members } - } #[cfg(test)] @@ -127,7 +126,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/dedicated_database_restoration.rs b/src/models/dedicated_database_restoration.rs new file mode 100644 index 0000000..e52fefd --- /dev/null +++ b/src/models/dedicated_database_restoration.rs @@ -0,0 +1,143 @@ +//! DedicatedDatabaseRestoration model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Restoration +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseRestoration { + /// Restoration ID. + #[serde(rename = "$id")] + pub id: String, + /// Restoration creation time in ISO 8601 format. + #[serde(rename = "$createdAt")] + pub created_at: String, + /// Database ID being restored into. + #[serde(rename = "databaseId")] + pub database_id: String, + /// Source database ID when restoring a backup into another database. + #[serde(rename = "sourceDatabaseId")] + pub source_database_id: String, + /// Project ID. + #[serde(rename = "projectId")] + pub project_id: String, + /// Backup ID used for restoration (null for PITR). + #[serde(rename = "backupId")] + pub backup_id: String, + /// Restoration type. Possible values: backup (restore from a specific backup + /// snapshot), pitr (point-in-time recovery to a specific timestamp). + #[serde(rename = "type")] + pub r#type: String, + /// Restoration status. Possible values: pending (queued for processing), + /// running (currently in progress), completed (successfully finished), failed + /// (encountered an error). + #[serde(rename = "status")] + pub status: String, + /// Target time for PITR restoration in ISO 8601 format. + #[serde(rename = "targetTime")] + pub target_time: String, + /// Restoration start time in ISO 8601 format. + #[serde(rename = "startedAt")] + pub started_at: String, + /// Restoration completion time in ISO 8601 format. + #[serde(rename = "completedAt")] + pub completed_at: String, + /// Error message if restoration failed. + #[serde(rename = "error")] + pub error: String, +} + +impl DedicatedDatabaseRestoration { + /// Get id + pub fn id(&self) -> &String { + &self.id + } + + /// Get created_at + pub fn created_at(&self) -> &String { + &self.created_at + } + + /// Get database_id + pub fn database_id(&self) -> &String { + &self.database_id + } + + /// Get source_database_id + pub fn source_database_id(&self) -> &String { + &self.source_database_id + } + + /// Get project_id + pub fn project_id(&self) -> &String { + &self.project_id + } + + /// Get backup_id + pub fn backup_id(&self) -> &String { + &self.backup_id + } + + /// Get r#type + pub fn r#type(&self) -> &String { + &self.r#type + } + + /// Get status + pub fn status(&self) -> &String { + &self.status + } + + /// Get target_time + pub fn target_time(&self) -> &String { + &self.target_time + } + + /// Get started_at + pub fn started_at(&self) -> &String { + &self.started_at + } + + /// Get completed_at + pub fn completed_at(&self) -> &String { + &self.completed_at + } + + /// Get error + pub fn error(&self) -> &String { + &self.error + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_restoration_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.database_id(); + let _ = _model.source_database_id(); + let _ = _model.project_id(); + let _ = _model.backup_id(); + let _ = _model.r#type(); + let _ = _model.status(); + let _ = _model.target_time(); + let _ = _model.started_at(); + let _ = _model.completed_at(); + let _ = _model.error(); + } + + #[test] + fn test_dedicated_database_restoration_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/dedicated_database_restoration_list.rs b/src/models/dedicated_database_restoration_list.rs new file mode 100644 index 0000000..3d24d00 --- /dev/null +++ b/src/models/dedicated_database_restoration_list.rs @@ -0,0 +1,50 @@ +//! DedicatedDatabaseRestorationList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Dedicated database restorations list +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct DedicatedDatabaseRestorationList { + /// Total number of restorations that matched your query. + #[serde(rename = "total")] + pub total: i64, + /// List of restorations. + #[serde(rename = "restorations")] + pub restorations: Vec, +} + +impl DedicatedDatabaseRestorationList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get restorations + pub fn restorations(&self) -> &Vec { + &self.restorations + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_dedicated_database_restoration_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.restorations(); + } + + #[test] + fn test_dedicated_database_restoration_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/dedicated_database_specification.rs b/src/models/dedicated_database_specification.rs index 182c6b9..bc94463 100644 --- a/src/models/dedicated_database_specification.rs +++ b/src/models/dedicated_database_specification.rs @@ -80,7 +80,6 @@ impl DedicatedDatabaseSpecification { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] @@ -107,7 +106,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/dedicated_database_specification_list.rs b/src/models/dedicated_database_specification_list.rs index cd592e7..2be3453 100644 --- a/src/models/dedicated_database_specification_list.rs +++ b/src/models/dedicated_database_specification_list.rs @@ -32,7 +32,6 @@ impl DedicatedDatabaseSpecificationList { pub fn pricing(&self) -> &crate::models::DedicatedDatabaseSpecificationPricing { &self.pricing } - } #[cfg(test)] @@ -53,7 +52,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/dedicated_database_specification_pricing.rs b/src/models/dedicated_database_specification_pricing.rs index 0191fe4..0842526 100644 --- a/src/models/dedicated_database_specification_pricing.rs +++ b/src/models/dedicated_database_specification_pricing.rs @@ -40,7 +40,6 @@ impl DedicatedDatabaseSpecificationPricing { pub fn pitr_rate(&self) -> &f64 { &self.pitr_rate } - } #[cfg(test)] @@ -62,7 +61,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/deployment.rs b/src/models/deployment.rs index 7d05805..2da7e6f 100644 --- a/src/models/deployment.rs +++ b/src/models/deployment.rs @@ -225,7 +225,6 @@ impl Deployment { pub fn provider_branch_url(&self) -> &String { &self.provider_branch_url } - } #[cfg(test)] diff --git a/src/models/deployment_list.rs b/src/models/deployment_list.rs index e93a127..5ee6ea7 100644 --- a/src/models/deployment_list.rs +++ b/src/models/deployment_list.rs @@ -24,7 +24,6 @@ impl DeploymentList { pub fn deployments(&self) -> &Vec { &self.deployments } - } #[cfg(test)] diff --git a/src/models/dev_key.rs b/src/models/dev_key.rs index c3b24f4..7b5ba1f 100644 --- a/src/models/dev_key.rs +++ b/src/models/dev_key.rs @@ -73,7 +73,6 @@ impl DevKey { pub fn sdks(&self) -> &Vec { &self.sdks } - } #[cfg(test)] diff --git a/src/models/document.rs b/src/models/document.rs index 48be74c..67c4a9c 100644 --- a/src/models/document.rs +++ b/src/models/document.rs @@ -70,9 +70,9 @@ impl Document { &self.permissions } - pub fn get(&self, key: &str) -> Option { - self.data.get(key) + self.data + .get(key) .and_then(|v| serde_json::from_value(v.clone()).ok()) } diff --git a/src/models/document_list.rs b/src/models/document_list.rs index ca513ad..bf9ba60 100644 --- a/src/models/document_list.rs +++ b/src/models/document_list.rs @@ -24,7 +24,6 @@ impl DocumentList { pub fn documents(&self) -> &Vec { &self.documents } - } #[cfg(test)] diff --git a/src/models/email_template.rs b/src/models/email_template.rs index 551ccf8..3236650 100644 --- a/src/models/email_template.rs +++ b/src/models/email_template.rs @@ -72,7 +72,6 @@ impl EmailTemplate { pub fn subject(&self) -> &String { &self.subject } - } #[cfg(test)] diff --git a/src/models/email_template_list.rs b/src/models/email_template_list.rs index dafab03..02dbf9a 100644 --- a/src/models/email_template_list.rs +++ b/src/models/email_template_list.rs @@ -24,7 +24,6 @@ impl EmailTemplateList { pub fn templates(&self) -> &Vec { &self.templates } - } #[cfg(test)] diff --git a/src/models/embedding.rs b/src/models/embedding.rs index 02bf7a5..1e26677 100644 --- a/src/models/embedding.rs +++ b/src/models/embedding.rs @@ -40,7 +40,6 @@ impl Embedding { pub fn error(&self) -> &String { &self.error } - } #[cfg(test)] diff --git a/src/models/embedding_list.rs b/src/models/embedding_list.rs index 6fe82c3..65f3074 100644 --- a/src/models/embedding_list.rs +++ b/src/models/embedding_list.rs @@ -24,7 +24,6 @@ impl EmbeddingList { pub fn embeddings(&self) -> &Vec { &self.embeddings } - } #[cfg(test)] diff --git a/src/models/ephemeral_key.rs b/src/models/ephemeral_key.rs index cee1521..091da9c 100644 --- a/src/models/ephemeral_key.rs +++ b/src/models/ephemeral_key.rs @@ -81,7 +81,6 @@ impl EphemeralKey { pub fn sdks(&self) -> &Vec { &self.sdks } - } #[cfg(test)] diff --git a/src/models/execution.rs b/src/models/execution.rs index 171b7a6..9591343 100644 --- a/src/models/execution.rs +++ b/src/models/execution.rs @@ -18,17 +18,20 @@ pub struct Execution { /// Execution roles. #[serde(rename = "$permissions")] pub permissions: Vec, - /// Function ID. - #[serde(rename = "functionId")] - pub function_id: String, - /// Function's deployment ID used to create the execution. + /// Function or site ID. + #[serde(rename = "resourceId")] + pub resource_id: String, + /// Execution resource type. + #[serde(rename = "resourceType")] + pub resource_type: crate::enums::ExecutionResourceType, + /// Deployment ID used to create the execution. #[serde(rename = "deploymentId")] pub deployment_id: String, - /// The trigger that caused the function to execute. Possible values can be: + /// The trigger that caused the resource to execute. Possible values can be: /// `http`, `schedule`, or `event`. #[serde(rename = "trigger")] pub trigger: crate::enums::ExecutionTrigger, - /// The status of the function execution. Possible values can be: `waiting`, + /// The status of the resource execution. Possible values can be: `waiting`, /// `processing`, `completed`, `failed`, or `scheduled`. #[serde(rename = "status")] pub status: crate::enums::ExecutionStatus, @@ -55,12 +58,12 @@ pub struct Execution { /// synchronous. #[serde(rename = "responseHeaders")] pub response_headers: Vec, - /// Function logs. Includes the last 4,000 characters. This will return an + /// Resource logs. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "logs")] pub logs: String, - /// Function errors. Includes the last 4,000 characters. This will return an + /// Resource errors. Includes the last 4,000 characters. This will return an /// empty string unless the response is returned using an API key or as part of /// a webhook payload. #[serde(rename = "errors")] @@ -96,9 +99,14 @@ impl Execution { &self.permissions } - /// Get function_id - pub fn function_id(&self) -> &String { - &self.function_id + /// Get resource_id + pub fn resource_id(&self) -> &String { + &self.resource_id + } + + /// Get resource_type + pub fn resource_type(&self) -> &crate::enums::ExecutionResourceType { + &self.resource_type } /// Get deployment_id @@ -171,7 +179,6 @@ impl Execution { pub fn scheduled_at(&self) -> Option<&String> { self.scheduled_at.as_ref() } - } #[cfg(test)] @@ -185,7 +192,8 @@ mod tests { let _ = _model.created_at(); let _ = _model.updated_at(); let _ = _model.permissions(); - let _ = _model.function_id(); + let _ = _model.resource_id(); + let _ = _model.resource_type(); let _ = _model.deployment_id(); let _ = _model.trigger(); let _ = _model.status(); diff --git a/src/models/execution_list.rs b/src/models/execution_list.rs index 0066b37..85fa76f 100644 --- a/src/models/execution_list.rs +++ b/src/models/execution_list.rs @@ -24,7 +24,6 @@ impl ExecutionList { pub fn executions(&self) -> &Vec { &self.executions } - } #[cfg(test)] diff --git a/src/models/file.rs b/src/models/file.rs index 9f0d6c9..1310f94 100644 --- a/src/models/file.rs +++ b/src/models/file.rs @@ -140,7 +140,6 @@ impl File { pub fn compression(&self) -> &String { &self.compression } - } #[cfg(test)] diff --git a/src/models/file_list.rs b/src/models/file_list.rs index 0a5ae54..bc9f598 100644 --- a/src/models/file_list.rs +++ b/src/models/file_list.rs @@ -24,7 +24,6 @@ impl FileList { pub fn files(&self) -> &Vec { &self.files } - } #[cfg(test)] diff --git a/src/models/framework.rs b/src/models/framework.rs index b495410..fbc7a82 100644 --- a/src/models/framework.rs +++ b/src/models/framework.rs @@ -48,7 +48,6 @@ impl Framework { pub fn adapters(&self) -> &Vec { &self.adapters } - } #[cfg(test)] diff --git a/src/models/framework_adapter.rs b/src/models/framework_adapter.rs index 699a661..3deecd6 100644 --- a/src/models/framework_adapter.rs +++ b/src/models/framework_adapter.rs @@ -49,7 +49,6 @@ impl FrameworkAdapter { pub fn fallback_file(&self) -> &String { &self.fallback_file } - } #[cfg(test)] diff --git a/src/models/framework_list.rs b/src/models/framework_list.rs index 386fa45..9d8570f 100644 --- a/src/models/framework_list.rs +++ b/src/models/framework_list.rs @@ -24,7 +24,6 @@ impl FrameworkList { pub fn frameworks(&self) -> &Vec { &self.frameworks } - } #[cfg(test)] diff --git a/src/models/function.rs b/src/models/function.rs index d3ec9a3..1865238 100644 --- a/src/models/function.rs +++ b/src/models/function.rs @@ -274,7 +274,6 @@ impl Function { pub fn runtime_specification(&self) -> &String { &self.runtime_specification } - } #[cfg(test)] diff --git a/src/models/function_list.rs b/src/models/function_list.rs index 4af367b..ff9a37d 100644 --- a/src/models/function_list.rs +++ b/src/models/function_list.rs @@ -24,7 +24,6 @@ impl FunctionList { pub fn functions(&self) -> &Vec { &self.functions } - } #[cfg(test)] diff --git a/src/models/headers.rs b/src/models/headers.rs index e357622..87a2b64 100644 --- a/src/models/headers.rs +++ b/src/models/headers.rs @@ -24,7 +24,6 @@ impl Headers { pub fn value(&self) -> &String { &self.value } - } #[cfg(test)] diff --git a/src/models/identity.rs b/src/models/identity.rs index ab32f8d..841a5ab 100644 --- a/src/models/identity.rs +++ b/src/models/identity.rs @@ -88,7 +88,6 @@ impl Identity { pub fn provider_refresh_token(&self) -> &String { &self.provider_refresh_token } - } #[cfg(test)] diff --git a/src/models/identity_list.rs b/src/models/identity_list.rs index 690fd7c..b8cca8a 100644 --- a/src/models/identity_list.rs +++ b/src/models/identity_list.rs @@ -24,7 +24,6 @@ impl IdentityList { pub fn identities(&self) -> &Vec { &self.identities } - } #[cfg(test)] diff --git a/src/models/index.rs b/src/models/index.rs index 819a1e6..d18b386 100644 --- a/src/models/index.rs +++ b/src/models/index.rs @@ -97,7 +97,6 @@ impl Index { pub fn orders(&self) -> Option<&Vec> { self.orders.as_ref() } - } #[cfg(test)] diff --git a/src/models/index_list.rs b/src/models/index_list.rs index b2d34b6..48eec9e 100644 --- a/src/models/index_list.rs +++ b/src/models/index_list.rs @@ -24,7 +24,6 @@ impl IndexList { pub fn indexes(&self) -> &Vec { &self.indexes } - } #[cfg(test)] diff --git a/src/models/insight.rs b/src/models/insight.rs index ea791a0..937d6f7 100644 --- a/src/models/insight.rs +++ b/src/models/insight.rs @@ -174,7 +174,6 @@ impl Insight { pub fn dismissed_by(&self) -> Option<&String> { self.dismissed_by.as_ref() } - } #[cfg(test)] diff --git a/src/models/insight_cta.rs b/src/models/insight_cta.rs index a551536..6a3b719 100644 --- a/src/models/insight_cta.rs +++ b/src/models/insight_cta.rs @@ -46,7 +46,6 @@ impl InsightCTA { pub fn params(&self) -> &serde_json::Value { &self.params } - } #[cfg(test)] diff --git a/src/models/insight_list.rs b/src/models/insight_list.rs index 09ce006..54b229c 100644 --- a/src/models/insight_list.rs +++ b/src/models/insight_list.rs @@ -24,7 +24,6 @@ impl InsightList { pub fn insights(&self) -> &Vec { &self.insights } - } #[cfg(test)] diff --git a/src/models/jwt.rs b/src/models/jwt.rs index 02d850d..8482207 100644 --- a/src/models/jwt.rs +++ b/src/models/jwt.rs @@ -16,7 +16,6 @@ impl Jwt { pub fn jwt(&self) -> &String { &self.jwt } - } #[cfg(test)] diff --git a/src/models/key.rs b/src/models/key.rs index 029dcd4..109b8d5 100644 --- a/src/models/key.rs +++ b/src/models/key.rs @@ -81,7 +81,6 @@ impl Key { pub fn sdks(&self) -> &Vec { &self.sdks } - } #[cfg(test)] diff --git a/src/models/key_list.rs b/src/models/key_list.rs index 7ffb2f6..0cad143 100644 --- a/src/models/key_list.rs +++ b/src/models/key_list.rs @@ -24,7 +24,6 @@ impl KeyList { pub fn keys(&self) -> &Vec { &self.keys } - } #[cfg(test)] diff --git a/src/models/language.rs b/src/models/language.rs index 7f91530..bef7ec4 100644 --- a/src/models/language.rs +++ b/src/models/language.rs @@ -32,7 +32,6 @@ impl Language { pub fn native_name(&self) -> &String { &self.native_name } - } #[cfg(test)] diff --git a/src/models/language_list.rs b/src/models/language_list.rs index 6b87091..42d79d9 100644 --- a/src/models/language_list.rs +++ b/src/models/language_list.rs @@ -24,7 +24,6 @@ impl LanguageList { pub fn languages(&self) -> &Vec { &self.languages } - } #[cfg(test)] diff --git a/src/models/locale.rs b/src/models/locale.rs index 0705722..08b7f02 100644 --- a/src/models/locale.rs +++ b/src/models/locale.rs @@ -180,7 +180,10 @@ impl Locale { } /// Set autonomous_system_organization - pub fn set_autonomous_system_organization(mut self, autonomous_system_organization: String) -> Self { + pub fn set_autonomous_system_organization( + mut self, + autonomous_system_organization: String, + ) -> Self { self.autonomous_system_organization = Some(autonomous_system_organization); self } @@ -233,7 +236,6 @@ impl Locale { pub fn connection_organization(&self) -> Option<&String> { self.connection_organization.as_ref() } - } #[cfg(test)] diff --git a/src/models/locale_code.rs b/src/models/locale_code.rs index 92750c9..389f8a2 100644 --- a/src/models/locale_code.rs +++ b/src/models/locale_code.rs @@ -25,7 +25,6 @@ impl LocaleCode { pub fn name(&self) -> &String { &self.name } - } #[cfg(test)] diff --git a/src/models/locale_code_list.rs b/src/models/locale_code_list.rs index d503d0a..e8e2ebb 100644 --- a/src/models/locale_code_list.rs +++ b/src/models/locale_code_list.rs @@ -24,7 +24,6 @@ impl LocaleCodeList { pub fn locale_codes(&self) -> &Vec { &self.locale_codes } - } #[cfg(test)] diff --git a/src/models/log.rs b/src/models/log.rs index a9a1553..c62709d 100644 --- a/src/models/log.rs +++ b/src/models/log.rs @@ -190,7 +190,6 @@ impl Log { pub fn country_name(&self) -> &String { &self.country_name } - } #[cfg(test)] diff --git a/src/models/log_list.rs b/src/models/log_list.rs index 696e194..8215ec2 100644 --- a/src/models/log_list.rs +++ b/src/models/log_list.rs @@ -24,7 +24,6 @@ impl LogList { pub fn logs(&self) -> &Vec { &self.logs } - } #[cfg(test)] diff --git a/src/models/membership.rs b/src/models/membership.rs index c07619c..da724ca 100644 --- a/src/models/membership.rs +++ b/src/models/membership.rs @@ -136,7 +136,6 @@ impl Membership { pub fn roles(&self) -> &Vec { &self.roles } - } #[cfg(test)] diff --git a/src/models/membership_list.rs b/src/models/membership_list.rs index 27e020d..628a569 100644 --- a/src/models/membership_list.rs +++ b/src/models/membership_list.rs @@ -24,7 +24,6 @@ impl MembershipList { pub fn memberships(&self) -> &Vec { &self.memberships } - } #[cfg(test)] diff --git a/src/models/message.rs b/src/models/message.rs index dcb4de3..554149b 100644 --- a/src/models/message.rs +++ b/src/models/message.rs @@ -133,7 +133,6 @@ impl Message { pub fn status(&self) -> &crate::enums::MessageStatus { &self.status } - } #[cfg(test)] diff --git a/src/models/message_list.rs b/src/models/message_list.rs index 6fc8614..de470cb 100644 --- a/src/models/message_list.rs +++ b/src/models/message_list.rs @@ -24,7 +24,6 @@ impl MessageList { pub fn messages(&self) -> &Vec { &self.messages } - } #[cfg(test)] diff --git a/src/models/mfa_challenge.rs b/src/models/mfa_challenge.rs index bb0b1bc..cee280b 100644 --- a/src/models/mfa_challenge.rs +++ b/src/models/mfa_challenge.rs @@ -40,7 +40,6 @@ impl MfaChallenge { pub fn expire(&self) -> &String { &self.expire } - } #[cfg(test)] diff --git a/src/models/mfa_challenge_secret.rs b/src/models/mfa_challenge_secret.rs index 59f5435..42a9c6e 100644 --- a/src/models/mfa_challenge_secret.rs +++ b/src/models/mfa_challenge_secret.rs @@ -48,7 +48,6 @@ impl MfaChallengeSecret { pub fn code(&self) -> &String { &self.code } - } #[cfg(test)] diff --git a/src/models/mfa_factors.rs b/src/models/mfa_factors.rs index 9d1305a..14b1ebf 100644 --- a/src/models/mfa_factors.rs +++ b/src/models/mfa_factors.rs @@ -48,7 +48,6 @@ impl MfaFactors { pub fn custom(&self) -> &bool { &self.custom } - } #[cfg(test)] diff --git a/src/models/mfa_recovery_codes.rs b/src/models/mfa_recovery_codes.rs index 3d79a88..44f77a3 100644 --- a/src/models/mfa_recovery_codes.rs +++ b/src/models/mfa_recovery_codes.rs @@ -16,7 +16,6 @@ impl MfaRecoveryCodes { pub fn recovery_codes(&self) -> &Vec { &self.recovery_codes } - } #[cfg(test)] diff --git a/src/models/mfa_type.rs b/src/models/mfa_type.rs index 6d870c7..7809d95 100644 --- a/src/models/mfa_type.rs +++ b/src/models/mfa_type.rs @@ -24,7 +24,6 @@ impl MfaType { pub fn uri(&self) -> &String { &self.uri } - } #[cfg(test)] diff --git a/src/models/mock_number.rs b/src/models/mock_number.rs index 1160f4c..1d8ea85 100644 --- a/src/models/mock_number.rs +++ b/src/models/mock_number.rs @@ -41,7 +41,6 @@ impl MockNumber { pub fn updated_at(&self) -> &String { &self.updated_at } - } #[cfg(test)] diff --git a/src/models/mock_number_list.rs b/src/models/mock_number_list.rs index 529c6eb..b4d7f7f 100644 --- a/src/models/mock_number_list.rs +++ b/src/models/mock_number_list.rs @@ -24,7 +24,6 @@ impl MockNumberList { pub fn mock_numbers(&self) -> &Vec { &self.mock_numbers } - } #[cfg(test)] diff --git a/src/models/mod.rs b/src/models/mod.rs index 3cf41db..75b3a93 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -88,6 +88,8 @@ pub mod transaction_list; pub use transaction_list::TransactionList; pub mod specification_list; pub use specification_list::SpecificationList; +pub mod vectorsdb_collection_list; +pub use vectorsdb_collection_list::VectorsdbCollectionList; pub mod embedding_list; pub use embedding_list::EmbeddingList; pub mod insight_list; @@ -138,6 +140,12 @@ pub mod attribute_mediumtext; pub use attribute_mediumtext::AttributeMediumtext; pub mod attribute_longtext; pub use attribute_longtext::AttributeLongtext; +pub mod vectorsdb_collection; +pub use vectorsdb_collection::VectorsdbCollection; +pub mod attribute_object; +pub use attribute_object::AttributeObject; +pub mod attribute_vector; +pub use attribute_vector::AttributeVector; pub mod table; pub use table::Table; pub mod column_list; @@ -308,6 +316,8 @@ pub mod o_auth2_salesforce; pub use o_auth2_salesforce::OAuth2Salesforce; pub mod o_auth2_yahoo; pub use o_auth2_yahoo::OAuth2Yahoo; +pub mod o_auth2_hugging_face; +pub use o_auth2_hugging_face::OAuth2HuggingFace; pub mod o_auth2_linkedin; pub use o_auth2_linkedin::OAuth2Linkedin; pub mod o_auth2_disqus; @@ -434,6 +444,12 @@ pub mod additional_resource; pub use additional_resource::AdditionalResource; pub mod backup_archive; pub use backup_archive::BackupArchive; +pub mod dedicated_database_backup; +pub use dedicated_database_backup::DedicatedDatabaseBackup; +pub mod dedicated_database_backup_list; +pub use dedicated_database_backup_list::DedicatedDatabaseBackupList; +pub mod dedicated_database_backup_storage; +pub use dedicated_database_backup_storage::DedicatedDatabaseBackupStorage; pub mod billing_limits; pub use billing_limits::BillingLimits; pub mod billing_plan; @@ -450,12 +466,24 @@ pub mod billing_plan_supported_addons; pub use billing_plan_supported_addons::BillingPlanSupportedAddons; pub mod block; pub use block::Block; +pub mod dedicated_database_branch; +pub use dedicated_database_branch::DedicatedDatabaseBranch; +pub mod dedicated_database_branch_list; +pub use dedicated_database_branch_list::DedicatedDatabaseBranchList; pub mod database_migration; pub use database_migration::DatabaseMigration; pub mod dedicated_database; pub use dedicated_database::DedicatedDatabase; +pub mod dedicated_database_execution; +pub use dedicated_database_execution::DedicatedDatabaseExecution; +pub mod dedicated_database_execution_column; +pub use dedicated_database_execution_column::DedicatedDatabaseExecutionColumn; +pub mod dedicated_database_restoration; +pub use dedicated_database_restoration::DedicatedDatabaseRestoration; pub mod database_status; pub use database_status::DatabaseStatus; +pub mod dedicated_database_extensions; +pub use dedicated_database_extensions::DedicatedDatabaseExtensions; pub mod dedicated_database_member; pub use dedicated_database_member::DedicatedDatabaseMember; pub mod dedicated_database_operation; @@ -468,6 +496,8 @@ pub mod proxy_invalidation; pub use proxy_invalidation::ProxyInvalidation; pub mod organization; pub use organization::Organization; +pub mod dedicated_database_pitr_windows; +pub use dedicated_database_pitr_windows::DedicatedDatabasePITRWindows; pub mod backup_policy; pub use backup_policy::BackupPolicy; pub mod policy_deny_aliased_email; @@ -478,10 +508,16 @@ pub mod policy_deny_free_email; pub use policy_deny_free_email::PolicyDenyFreeEmail; pub mod policy_deny_corporate_email; pub use policy_deny_corporate_email::PolicyDenyCorporateEmail; +pub mod dedicated_database_pooler; +pub use dedicated_database_pooler::DedicatedDatabasePooler; +pub mod postgres_extension; +pub use postgres_extension::PostgresExtension; pub mod program; pub use program::Program; pub mod backup_restoration; pub use backup_restoration::BackupRestoration; +pub mod dedicated_database_restoration_list; +pub use dedicated_database_restoration_list::DedicatedDatabaseRestorationList; pub mod dedicated_database_specification; pub use dedicated_database_specification::DedicatedDatabaseSpecification; pub mod dedicated_database_specification_list; @@ -548,6 +584,8 @@ pub mod backup_restoration_list; pub use backup_restoration_list::BackupRestorationList; pub mod database_migration_list; pub use database_migration_list::DatabaseMigrationList; +pub mod dedicated_database_list; +pub use dedicated_database_list::DedicatedDatabaseList; pub mod apps_list; pub use apps_list::AppsList; pub mod app_secret_list; @@ -610,6 +648,7 @@ impl Model for SubscriberList {} impl Model for TargetList {} impl Model for TransactionList {} impl Model for SpecificationList {} +impl Model for VectorsdbCollectionList {} impl Model for EmbeddingList {} impl Model for InsightList {} impl Model for ReportList {} @@ -635,6 +674,9 @@ impl Model for AttributeVarchar {} impl Model for AttributeText {} impl Model for AttributeMediumtext {} impl Model for AttributeLongtext {} +impl Model for VectorsdbCollection {} +impl Model for AttributeObject {} +impl Model for AttributeVector {} impl Model for Table {} impl Model for ColumnList {} impl Model for ColumnString {} @@ -720,6 +762,7 @@ impl Model for OAuth2Podio {} impl Model for OAuth2Notion {} impl Model for OAuth2Salesforce {} impl Model for OAuth2Yahoo {} +impl Model for OAuth2HuggingFace {} impl Model for OAuth2Linkedin {} impl Model for OAuth2Disqus {} impl Model for OAuth2Amazon {} @@ -783,6 +826,9 @@ impl Model for Report {} impl Model for ActivityEvent {} impl Model for AdditionalResource {} impl Model for BackupArchive {} +impl Model for DedicatedDatabaseBackup {} +impl Model for DedicatedDatabaseBackupList {} +impl Model for DedicatedDatabaseBackupStorage {} impl Model for BillingLimits {} impl Model for BillingPlan {} impl Model for BillingPlanAddon {} @@ -791,22 +837,32 @@ impl Model for BillingPlanLimits {} impl Model for BillingPlanDedicatedDatabaseLimits {} impl Model for BillingPlanSupportedAddons {} impl Model for Block {} +impl Model for DedicatedDatabaseBranch {} +impl Model for DedicatedDatabaseBranchList {} impl Model for DatabaseMigration {} impl Model for DedicatedDatabase {} +impl Model for DedicatedDatabaseExecution {} +impl Model for DedicatedDatabaseExecutionColumn {} +impl Model for DedicatedDatabaseRestoration {} impl Model for DatabaseStatus {} +impl Model for DedicatedDatabaseExtensions {} impl Model for DedicatedDatabaseMember {} impl Model for DedicatedDatabaseOperation {} impl Model for DedicatedDatabaseOperationList {} impl Model for DedicatedDatabaseReplicas {} impl Model for ProxyInvalidation {} impl Model for Organization {} +impl Model for DedicatedDatabasePITRWindows {} impl Model for BackupPolicy {} impl Model for PolicyDenyAliasedEmail {} impl Model for PolicyDenyDisposableEmail {} impl Model for PolicyDenyFreeEmail {} impl Model for PolicyDenyCorporateEmail {} +impl Model for DedicatedDatabasePooler {} +impl Model for PostgresExtension {} impl Model for Program {} impl Model for BackupRestoration {} +impl Model for DedicatedDatabaseRestorationList {} impl Model for DedicatedDatabaseSpecification {} impl Model for DedicatedDatabaseSpecificationList {} impl Model for DedicatedDatabaseSpecificationPricing {} @@ -840,6 +896,7 @@ impl Model for BackupArchiveList {} impl Model for BackupPolicyList {} impl Model for BackupRestorationList {} impl Model for DatabaseMigrationList {} +impl Model for DedicatedDatabaseList {} impl Model for AppsList {} impl Model for AppSecretList {} impl Model for AppScopeList {} diff --git a/src/models/o_auth2_amazon.rs b/src/models/o_auth2_amazon.rs index 78418c0..c2359b9 100644 --- a/src/models/o_auth2_amazon.rs +++ b/src/models/o_auth2_amazon.rs @@ -40,7 +40,6 @@ impl OAuth2Amazon { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_apple.rs b/src/models/o_auth2_apple.rs index 955c5b1..47a2616 100644 --- a/src/models/o_auth2_apple.rs +++ b/src/models/o_auth2_apple.rs @@ -57,7 +57,6 @@ impl OAuth2Apple { pub fn p8_file(&self) -> &String { &self.p8_file } - } #[cfg(test)] diff --git a/src/models/o_auth2_appwrite.rs b/src/models/o_auth2_appwrite.rs index 14c645a..4ca0449 100644 --- a/src/models/o_auth2_appwrite.rs +++ b/src/models/o_auth2_appwrite.rs @@ -40,7 +40,6 @@ impl OAuth2Appwrite { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_auth0.rs b/src/models/o_auth2_auth0.rs index b9a6781..0242284 100644 --- a/src/models/o_auth2_auth0.rs +++ b/src/models/o_auth2_auth0.rs @@ -48,7 +48,6 @@ impl OAuth2Auth0 { pub fn endpoint(&self) -> &String { &self.endpoint } - } #[cfg(test)] diff --git a/src/models/o_auth2_authentik.rs b/src/models/o_auth2_authentik.rs index 1b6e07e..da60963 100644 --- a/src/models/o_auth2_authentik.rs +++ b/src/models/o_auth2_authentik.rs @@ -48,7 +48,6 @@ impl OAuth2Authentik { pub fn endpoint(&self) -> &String { &self.endpoint } - } #[cfg(test)] diff --git a/src/models/o_auth2_autodesk.rs b/src/models/o_auth2_autodesk.rs index 7f626ad..a487d8a 100644 --- a/src/models/o_auth2_autodesk.rs +++ b/src/models/o_auth2_autodesk.rs @@ -40,7 +40,6 @@ impl OAuth2Autodesk { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_bitbucket.rs b/src/models/o_auth2_bitbucket.rs index 8686f10..cfe595b 100644 --- a/src/models/o_auth2_bitbucket.rs +++ b/src/models/o_auth2_bitbucket.rs @@ -40,7 +40,6 @@ impl OAuth2Bitbucket { pub fn secret(&self) -> &String { &self.secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_bitly.rs b/src/models/o_auth2_bitly.rs index 92032f0..15a0774 100644 --- a/src/models/o_auth2_bitly.rs +++ b/src/models/o_auth2_bitly.rs @@ -40,7 +40,6 @@ impl OAuth2Bitly { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_box.rs b/src/models/o_auth2_box.rs index 1e45e46..83959c8 100644 --- a/src/models/o_auth2_box.rs +++ b/src/models/o_auth2_box.rs @@ -40,7 +40,6 @@ impl OAuth2Box { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_dailymotion.rs b/src/models/o_auth2_dailymotion.rs index 1362994..b94e6bc 100644 --- a/src/models/o_auth2_dailymotion.rs +++ b/src/models/o_auth2_dailymotion.rs @@ -40,7 +40,6 @@ impl OAuth2Dailymotion { pub fn api_secret(&self) -> &String { &self.api_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_discord.rs b/src/models/o_auth2_discord.rs index 900ba2f..0f24f6e 100644 --- a/src/models/o_auth2_discord.rs +++ b/src/models/o_auth2_discord.rs @@ -40,7 +40,6 @@ impl OAuth2Discord { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_disqus.rs b/src/models/o_auth2_disqus.rs index 75a3e31..467e840 100644 --- a/src/models/o_auth2_disqus.rs +++ b/src/models/o_auth2_disqus.rs @@ -40,7 +40,6 @@ impl OAuth2Disqus { pub fn secret_key(&self) -> &String { &self.secret_key } - } #[cfg(test)] diff --git a/src/models/o_auth2_dropbox.rs b/src/models/o_auth2_dropbox.rs index a30d655..d566903 100644 --- a/src/models/o_auth2_dropbox.rs +++ b/src/models/o_auth2_dropbox.rs @@ -40,7 +40,6 @@ impl OAuth2Dropbox { pub fn app_secret(&self) -> &String { &self.app_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_etsy.rs b/src/models/o_auth2_etsy.rs index 9e3fef4..cf6bab9 100644 --- a/src/models/o_auth2_etsy.rs +++ b/src/models/o_auth2_etsy.rs @@ -40,7 +40,6 @@ impl OAuth2Etsy { pub fn shared_secret(&self) -> &String { &self.shared_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_facebook.rs b/src/models/o_auth2_facebook.rs index e510a84..c8c3bd9 100644 --- a/src/models/o_auth2_facebook.rs +++ b/src/models/o_auth2_facebook.rs @@ -40,7 +40,6 @@ impl OAuth2Facebook { pub fn app_secret(&self) -> &String { &self.app_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_figma.rs b/src/models/o_auth2_figma.rs index 69a9ca6..0ef3e3b 100644 --- a/src/models/o_auth2_figma.rs +++ b/src/models/o_auth2_figma.rs @@ -40,7 +40,6 @@ impl OAuth2Figma { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_fusion_auth.rs b/src/models/o_auth2_fusion_auth.rs index 8780541..2222752 100644 --- a/src/models/o_auth2_fusion_auth.rs +++ b/src/models/o_auth2_fusion_auth.rs @@ -48,7 +48,6 @@ impl OAuth2FusionAuth { pub fn endpoint(&self) -> &String { &self.endpoint } - } #[cfg(test)] diff --git a/src/models/o_auth2_github.rs b/src/models/o_auth2_github.rs index 993ac30..34d2137 100644 --- a/src/models/o_auth2_github.rs +++ b/src/models/o_auth2_github.rs @@ -41,7 +41,6 @@ impl OAuth2Github { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_gitlab.rs b/src/models/o_auth2_gitlab.rs index a61dba2..8444d1b 100644 --- a/src/models/o_auth2_gitlab.rs +++ b/src/models/o_auth2_gitlab.rs @@ -49,7 +49,6 @@ impl OAuth2Gitlab { pub fn endpoint(&self) -> &String { &self.endpoint } - } #[cfg(test)] diff --git a/src/models/o_auth2_google.rs b/src/models/o_auth2_google.rs index d25248e..0fcb39b 100644 --- a/src/models/o_auth2_google.rs +++ b/src/models/o_auth2_google.rs @@ -48,7 +48,6 @@ impl OAuth2Google { pub fn prompt(&self) -> &Vec { &self.prompt } - } #[cfg(test)] diff --git a/src/models/o_auth2_hugging_face.rs b/src/models/o_auth2_hugging_face.rs new file mode 100644 index 0000000..6259543 --- /dev/null +++ b/src/models/o_auth2_hugging_face.rs @@ -0,0 +1,67 @@ +//! OAuth2HuggingFace model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// OAuth2HuggingFace +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct OAuth2HuggingFace { + /// OAuth2 provider ID. + #[serde(rename = "$id")] + pub id: String, + /// OAuth2 provider is active and can be used to create sessions. + #[serde(rename = "enabled")] + pub enabled: bool, + /// Hugging Face OAuth2 client ID. + #[serde(rename = "clientId")] + pub client_id: String, + /// Hugging Face OAuth2 client secret. + #[serde(rename = "clientSecret")] + pub client_secret: String, +} + +impl OAuth2HuggingFace { + /// 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_hugging_face_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.enabled(); + let _ = _model.client_id(); + let _ = _model.client_secret(); + } + + #[test] + fn test_o_auth2_hugging_face_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_keycloak.rs b/src/models/o_auth2_keycloak.rs index f19d90a..1586924 100644 --- a/src/models/o_auth2_keycloak.rs +++ b/src/models/o_auth2_keycloak.rs @@ -56,7 +56,6 @@ impl OAuth2Keycloak { pub fn realm_name(&self) -> &String { &self.realm_name } - } #[cfg(test)] diff --git a/src/models/o_auth2_kick.rs b/src/models/o_auth2_kick.rs index 19aa598..d3f982f 100644 --- a/src/models/o_auth2_kick.rs +++ b/src/models/o_auth2_kick.rs @@ -40,7 +40,6 @@ impl OAuth2Kick { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_linkedin.rs b/src/models/o_auth2_linkedin.rs index c9e9275..1c1077e 100644 --- a/src/models/o_auth2_linkedin.rs +++ b/src/models/o_auth2_linkedin.rs @@ -40,7 +40,6 @@ impl OAuth2Linkedin { pub fn primary_client_secret(&self) -> &String { &self.primary_client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_microsoft.rs b/src/models/o_auth2_microsoft.rs index 42a659f..b871f19 100644 --- a/src/models/o_auth2_microsoft.rs +++ b/src/models/o_auth2_microsoft.rs @@ -49,7 +49,6 @@ impl OAuth2Microsoft { pub fn tenant(&self) -> &String { &self.tenant } - } #[cfg(test)] diff --git a/src/models/o_auth2_notion.rs b/src/models/o_auth2_notion.rs index 84436e3..c42807b 100644 --- a/src/models/o_auth2_notion.rs +++ b/src/models/o_auth2_notion.rs @@ -40,7 +40,6 @@ impl OAuth2Notion { pub fn oauth_client_secret(&self) -> &String { &self.oauth_client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_oidc.rs b/src/models/o_auth2_oidc.rs index 3b84ae4..010281d 100644 --- a/src/models/o_auth2_oidc.rs +++ b/src/models/o_auth2_oidc.rs @@ -98,7 +98,6 @@ impl OAuth2Oidc { pub fn max_age(&self) -> Option<&i64> { self.max_age.as_ref() } - } #[cfg(test)] diff --git a/src/models/o_auth2_okta.rs b/src/models/o_auth2_okta.rs index 5377c79..1c217d7 100644 --- a/src/models/o_auth2_okta.rs +++ b/src/models/o_auth2_okta.rs @@ -56,7 +56,6 @@ impl OAuth2Okta { pub fn authorization_server_id(&self) -> &String { &self.authorization_server_id } - } #[cfg(test)] diff --git a/src/models/o_auth2_paypal.rs b/src/models/o_auth2_paypal.rs index 621c321..41539e5 100644 --- a/src/models/o_auth2_paypal.rs +++ b/src/models/o_auth2_paypal.rs @@ -40,7 +40,6 @@ impl OAuth2Paypal { pub fn secret_key(&self) -> &String { &self.secret_key } - } #[cfg(test)] diff --git a/src/models/o_auth2_podio.rs b/src/models/o_auth2_podio.rs index e8a8b16..87bb74a 100644 --- a/src/models/o_auth2_podio.rs +++ b/src/models/o_auth2_podio.rs @@ -40,7 +40,6 @@ impl OAuth2Podio { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_provider_list.rs b/src/models/o_auth2_provider_list.rs index ae2eff7..a3354d1 100644 --- a/src/models/o_auth2_provider_list.rs +++ b/src/models/o_auth2_provider_list.rs @@ -24,7 +24,6 @@ impl OAuth2ProviderList { pub fn providers(&self) -> &Vec { &self.providers } - } #[cfg(test)] diff --git a/src/models/o_auth2_salesforce.rs b/src/models/o_auth2_salesforce.rs index 0245d0f..cfcbf76 100644 --- a/src/models/o_auth2_salesforce.rs +++ b/src/models/o_auth2_salesforce.rs @@ -40,7 +40,6 @@ impl OAuth2Salesforce { pub fn customer_secret(&self) -> &String { &self.customer_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_slack.rs b/src/models/o_auth2_slack.rs index 710e36a..3045596 100644 --- a/src/models/o_auth2_slack.rs +++ b/src/models/o_auth2_slack.rs @@ -40,7 +40,6 @@ impl OAuth2Slack { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_spotify.rs b/src/models/o_auth2_spotify.rs index ee90142..00572b9 100644 --- a/src/models/o_auth2_spotify.rs +++ b/src/models/o_auth2_spotify.rs @@ -40,7 +40,6 @@ impl OAuth2Spotify { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_stripe.rs b/src/models/o_auth2_stripe.rs index 556c54a..5b1565d 100644 --- a/src/models/o_auth2_stripe.rs +++ b/src/models/o_auth2_stripe.rs @@ -40,7 +40,6 @@ impl OAuth2Stripe { pub fn api_secret_key(&self) -> &String { &self.api_secret_key } - } #[cfg(test)] diff --git a/src/models/o_auth2_tradeshift.rs b/src/models/o_auth2_tradeshift.rs index 188c03c..ba79a82 100644 --- a/src/models/o_auth2_tradeshift.rs +++ b/src/models/o_auth2_tradeshift.rs @@ -40,7 +40,6 @@ impl OAuth2Tradeshift { pub fn oauth2_client_secret(&self) -> &String { &self.oauth2_client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_twitch.rs b/src/models/o_auth2_twitch.rs index 0fd83a2..e0550f7 100644 --- a/src/models/o_auth2_twitch.rs +++ b/src/models/o_auth2_twitch.rs @@ -40,7 +40,6 @@ impl OAuth2Twitch { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_word_press.rs b/src/models/o_auth2_word_press.rs index b88e45f..a340ebc 100644 --- a/src/models/o_auth2_word_press.rs +++ b/src/models/o_auth2_word_press.rs @@ -40,7 +40,6 @@ impl OAuth2WordPress { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_x.rs b/src/models/o_auth2_x.rs index 5f56cb7..c3c4f83 100644 --- a/src/models/o_auth2_x.rs +++ b/src/models/o_auth2_x.rs @@ -40,7 +40,6 @@ impl OAuth2X { pub fn secret_key(&self) -> &String { &self.secret_key } - } #[cfg(test)] diff --git a/src/models/o_auth2_yahoo.rs b/src/models/o_auth2_yahoo.rs index f9e9b05..18c69b1 100644 --- a/src/models/o_auth2_yahoo.rs +++ b/src/models/o_auth2_yahoo.rs @@ -40,7 +40,6 @@ impl OAuth2Yahoo { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_yandex.rs b/src/models/o_auth2_yandex.rs index 594f327..9db7bc6 100644 --- a/src/models/o_auth2_yandex.rs +++ b/src/models/o_auth2_yandex.rs @@ -40,7 +40,6 @@ impl OAuth2Yandex { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_zoho.rs b/src/models/o_auth2_zoho.rs index 281822a..e0fc894 100644 --- a/src/models/o_auth2_zoho.rs +++ b/src/models/o_auth2_zoho.rs @@ -40,7 +40,6 @@ impl OAuth2Zoho { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/o_auth2_zoom.rs b/src/models/o_auth2_zoom.rs index 9b05a80..e0047c3 100644 --- a/src/models/o_auth2_zoom.rs +++ b/src/models/o_auth2_zoom.rs @@ -40,7 +40,6 @@ impl OAuth2Zoom { pub fn client_secret(&self) -> &String { &self.client_secret } - } #[cfg(test)] diff --git a/src/models/oauth2_approve.rs b/src/models/oauth2_approve.rs index b76a5cf..a946f11 100644 --- a/src/models/oauth2_approve.rs +++ b/src/models/oauth2_approve.rs @@ -18,7 +18,6 @@ impl Oauth2Approve { pub fn redirect_url(&self) -> &String { &self.redirect_url } - } #[cfg(test)] diff --git a/src/models/oauth2_authorize.rs b/src/models/oauth2_authorize.rs index 7ad515f..5063ed7 100644 --- a/src/models/oauth2_authorize.rs +++ b/src/models/oauth2_authorize.rs @@ -27,7 +27,6 @@ impl Oauth2Authorize { pub fn redirect_url(&self) -> &String { &self.redirect_url } - } #[cfg(test)] diff --git a/src/models/oauth2_consent.rs b/src/models/oauth2_consent.rs index 9b98572..995d15b 100644 --- a/src/models/oauth2_consent.rs +++ b/src/models/oauth2_consent.rs @@ -92,7 +92,6 @@ impl Oauth2Consent { pub fn expire(&self) -> &String { &self.expire } - } #[cfg(test)] diff --git a/src/models/oauth2_consent_list.rs b/src/models/oauth2_consent_list.rs index 253c12d..3982df2 100644 --- a/src/models/oauth2_consent_list.rs +++ b/src/models/oauth2_consent_list.rs @@ -24,7 +24,6 @@ impl Oauth2ConsentList { pub fn consents(&self) -> &Vec { &self.consents } - } #[cfg(test)] diff --git a/src/models/oauth2_consent_token.rs b/src/models/oauth2_consent_token.rs index 1775207..4d2f43f 100644 --- a/src/models/oauth2_consent_token.rs +++ b/src/models/oauth2_consent_token.rs @@ -101,7 +101,6 @@ impl Oauth2ConsentToken { pub fn expire(&self) -> &String { &self.expire } - } #[cfg(test)] diff --git a/src/models/oauth2_consent_token_list.rs b/src/models/oauth2_consent_token_list.rs index b34d53f..9f5f5ad 100644 --- a/src/models/oauth2_consent_token_list.rs +++ b/src/models/oauth2_consent_token_list.rs @@ -24,7 +24,6 @@ impl Oauth2ConsentTokenList { pub fn tokens(&self) -> &Vec { &self.tokens } - } #[cfg(test)] diff --git a/src/models/oauth2_device_authorization.rs b/src/models/oauth2_device_authorization.rs index d3f7e24..80feee2 100644 --- a/src/models/oauth2_device_authorization.rs +++ b/src/models/oauth2_device_authorization.rs @@ -56,7 +56,6 @@ impl Oauth2DeviceAuthorization { pub fn interval(&self) -> &i64 { &self.interval } - } #[cfg(test)] @@ -80,7 +79,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/oauth2_grant.rs b/src/models/oauth2_grant.rs index 017f2bb..16d716d 100644 --- a/src/models/oauth2_grant.rs +++ b/src/models/oauth2_grant.rs @@ -107,7 +107,6 @@ impl Oauth2Grant { pub fn expire(&self) -> &String { &self.expire } - } #[cfg(test)] diff --git a/src/models/oauth2_organization.rs b/src/models/oauth2_organization.rs index d35fac3..b2c20fc 100644 --- a/src/models/oauth2_organization.rs +++ b/src/models/oauth2_organization.rs @@ -16,7 +16,6 @@ impl Oauth2Organization { pub fn id(&self) -> &String { &self.id } - } #[cfg(test)] diff --git a/src/models/oauth2_organization_list.rs b/src/models/oauth2_organization_list.rs index 9eea78e..1309964 100644 --- a/src/models/oauth2_organization_list.rs +++ b/src/models/oauth2_organization_list.rs @@ -24,7 +24,6 @@ impl Oauth2OrganizationList { pub fn organizations(&self) -> &Vec { &self.organizations } - } #[cfg(test)] diff --git a/src/models/oauth2_par.rs b/src/models/oauth2_par.rs index b5fa3d5..f1d779e 100644 --- a/src/models/oauth2_par.rs +++ b/src/models/oauth2_par.rs @@ -24,7 +24,6 @@ impl Oauth2PAR { pub fn expires_in(&self) -> &i64 { &self.expires_in } - } #[cfg(test)] diff --git a/src/models/oauth2_project.rs b/src/models/oauth2_project.rs index a2b8913..5af4e85 100644 --- a/src/models/oauth2_project.rs +++ b/src/models/oauth2_project.rs @@ -33,7 +33,6 @@ impl Oauth2Project { pub fn endpoint(&self) -> &String { &self.endpoint } - } #[cfg(test)] diff --git a/src/models/oauth2_project_list.rs b/src/models/oauth2_project_list.rs index 1d2c3bb..2e849fb 100644 --- a/src/models/oauth2_project_list.rs +++ b/src/models/oauth2_project_list.rs @@ -24,7 +24,6 @@ impl Oauth2ProjectList { pub fn projects(&self) -> &Vec { &self.projects } - } #[cfg(test)] diff --git a/src/models/oauth2_reject.rs b/src/models/oauth2_reject.rs index b7d9538..5daab49 100644 --- a/src/models/oauth2_reject.rs +++ b/src/models/oauth2_reject.rs @@ -17,7 +17,6 @@ impl Oauth2Reject { pub fn redirect_url(&self) -> &String { &self.redirect_url } - } #[cfg(test)] diff --git a/src/models/oauth2_token.rs b/src/models/oauth2_token.rs index 0967fc9..37b8552 100644 --- a/src/models/oauth2_token.rs +++ b/src/models/oauth2_token.rs @@ -78,7 +78,6 @@ impl Oauth2Token { pub fn id_token(&self) -> Option<&String> { self.id_token.as_ref() } - } #[cfg(test)] diff --git a/src/models/organization.rs b/src/models/organization.rs index 81ebd67..f7ec61d 100644 --- a/src/models/organization.rs +++ b/src/models/organization.rs @@ -311,7 +311,10 @@ impl Organization { } /// Set program_discord_channel_name - pub fn set_program_discord_channel_name(mut self, program_discord_channel_name: String) -> Self { + pub fn set_program_discord_channel_name( + mut self, + program_discord_channel_name: String, + ) -> Self { self.program_discord_channel_name = Some(program_discord_channel_name); self } @@ -379,7 +382,6 @@ impl Organization { pub fn projects(&self) -> &Vec { &self.projects } - } #[cfg(test)] diff --git a/src/models/phone.rs b/src/models/phone.rs index 6972713..2d6a27c 100644 --- a/src/models/phone.rs +++ b/src/models/phone.rs @@ -32,7 +32,6 @@ impl Phone { pub fn country_name(&self) -> &String { &self.country_name } - } #[cfg(test)] diff --git a/src/models/phone_list.rs b/src/models/phone_list.rs index 7ba3216..53939ae 100644 --- a/src/models/phone_list.rs +++ b/src/models/phone_list.rs @@ -24,7 +24,6 @@ impl PhoneList { pub fn phones(&self) -> &Vec { &self.phones } - } #[cfg(test)] diff --git a/src/models/platform_android.rs b/src/models/platform_android.rs index dccf75d..e4144a1 100644 --- a/src/models/platform_android.rs +++ b/src/models/platform_android.rs @@ -56,7 +56,6 @@ impl PlatformAndroid { pub fn application_id(&self) -> &String { &self.application_id } - } #[cfg(test)] diff --git a/src/models/platform_apple.rs b/src/models/platform_apple.rs index 378aea9..c157274 100644 --- a/src/models/platform_apple.rs +++ b/src/models/platform_apple.rs @@ -56,7 +56,6 @@ impl PlatformApple { pub fn bundle_identifier(&self) -> &String { &self.bundle_identifier } - } #[cfg(test)] diff --git a/src/models/platform_linux.rs b/src/models/platform_linux.rs index 28b1edb..d305b51 100644 --- a/src/models/platform_linux.rs +++ b/src/models/platform_linux.rs @@ -56,7 +56,6 @@ impl PlatformLinux { pub fn package_name(&self) -> &String { &self.package_name } - } #[cfg(test)] diff --git a/src/models/platform_list.rs b/src/models/platform_list.rs index e32939f..523fc50 100644 --- a/src/models/platform_list.rs +++ b/src/models/platform_list.rs @@ -24,7 +24,6 @@ impl PlatformList { pub fn platforms(&self) -> &Vec { &self.platforms } - } #[cfg(test)] diff --git a/src/models/platform_web.rs b/src/models/platform_web.rs index 9c954ff..5daea92 100644 --- a/src/models/platform_web.rs +++ b/src/models/platform_web.rs @@ -56,7 +56,6 @@ impl PlatformWeb { pub fn hostname(&self) -> &String { &self.hostname } - } #[cfg(test)] diff --git a/src/models/platform_windows.rs b/src/models/platform_windows.rs index ae38914..da5c08f 100644 --- a/src/models/platform_windows.rs +++ b/src/models/platform_windows.rs @@ -56,7 +56,6 @@ impl PlatformWindows { pub fn package_identifier_name(&self) -> &String { &self.package_identifier_name } - } #[cfg(test)] diff --git a/src/models/policy_deny_aliased_email.rs b/src/models/policy_deny_aliased_email.rs index d7ba233..c7327b0 100644 --- a/src/models/policy_deny_aliased_email.rs +++ b/src/models/policy_deny_aliased_email.rs @@ -24,7 +24,6 @@ impl PolicyDenyAliasedEmail { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/policy_deny_corporate_email.rs b/src/models/policy_deny_corporate_email.rs index 5e37d29..8b271b9 100644 --- a/src/models/policy_deny_corporate_email.rs +++ b/src/models/policy_deny_corporate_email.rs @@ -24,7 +24,6 @@ impl PolicyDenyCorporateEmail { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] @@ -44,7 +43,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/policy_deny_disposable_email.rs b/src/models/policy_deny_disposable_email.rs index 2c8cfc2..029a4fe 100644 --- a/src/models/policy_deny_disposable_email.rs +++ b/src/models/policy_deny_disposable_email.rs @@ -24,7 +24,6 @@ impl PolicyDenyDisposableEmail { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] @@ -44,7 +43,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/policy_deny_free_email.rs b/src/models/policy_deny_free_email.rs index a193cbd..6038f66 100644 --- a/src/models/policy_deny_free_email.rs +++ b/src/models/policy_deny_free_email.rs @@ -24,7 +24,6 @@ impl PolicyDenyFreeEmail { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/policy_list.rs b/src/models/policy_list.rs index d2dd492..559b319 100644 --- a/src/models/policy_list.rs +++ b/src/models/policy_list.rs @@ -24,7 +24,6 @@ impl PolicyList { pub fn policies(&self) -> &Vec { &self.policies } - } #[cfg(test)] diff --git a/src/models/policy_membership_privacy.rs b/src/models/policy_membership_privacy.rs index 8e75f48..8b17314 100644 --- a/src/models/policy_membership_privacy.rs +++ b/src/models/policy_membership_privacy.rs @@ -64,7 +64,6 @@ impl PolicyMembershipPrivacy { pub fn user_accessed_at(&self) -> &bool { &self.user_accessed_at } - } #[cfg(test)] diff --git a/src/models/policy_mfa_factors.rs b/src/models/policy_mfa_factors.rs index 2e1585d..a6634b6 100644 --- a/src/models/policy_mfa_factors.rs +++ b/src/models/policy_mfa_factors.rs @@ -48,7 +48,6 @@ impl PolicyMfaFactors { pub fn custom(&self) -> &bool { &self.custom } - } #[cfg(test)] diff --git a/src/models/policy_password_dictionary.rs b/src/models/policy_password_dictionary.rs index 52bb423..e14d27b 100644 --- a/src/models/policy_password_dictionary.rs +++ b/src/models/policy_password_dictionary.rs @@ -24,7 +24,6 @@ impl PolicyPasswordDictionary { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] @@ -44,7 +43,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/policy_password_history.rs b/src/models/policy_password_history.rs index 551e1ab..6f00db0 100644 --- a/src/models/policy_password_history.rs +++ b/src/models/policy_password_history.rs @@ -24,7 +24,6 @@ impl PolicyPasswordHistory { pub fn total(&self) -> &i64 { &self.total } - } #[cfg(test)] diff --git a/src/models/policy_password_personal_data.rs b/src/models/policy_password_personal_data.rs index baae9e8..6fee0df 100644 --- a/src/models/policy_password_personal_data.rs +++ b/src/models/policy_password_personal_data.rs @@ -24,7 +24,6 @@ impl PolicyPasswordPersonalData { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] @@ -44,7 +43,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/policy_password_strength.rs b/src/models/policy_password_strength.rs index bbdb10b..fa3b56a 100644 --- a/src/models/policy_password_strength.rs +++ b/src/models/policy_password_strength.rs @@ -56,7 +56,6 @@ impl PolicyPasswordStrength { pub fn symbols(&self) -> &bool { &self.symbols } - } #[cfg(test)] diff --git a/src/models/policy_session_alert.rs b/src/models/policy_session_alert.rs index e59058e..3689003 100644 --- a/src/models/policy_session_alert.rs +++ b/src/models/policy_session_alert.rs @@ -24,7 +24,6 @@ impl PolicySessionAlert { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/policy_session_duration.rs b/src/models/policy_session_duration.rs index 6860f60..4cf1a79 100644 --- a/src/models/policy_session_duration.rs +++ b/src/models/policy_session_duration.rs @@ -24,7 +24,6 @@ impl PolicySessionDuration { pub fn duration(&self) -> &i64 { &self.duration } - } #[cfg(test)] diff --git a/src/models/policy_session_invalidation.rs b/src/models/policy_session_invalidation.rs index 8afb7f7..07846c9 100644 --- a/src/models/policy_session_invalidation.rs +++ b/src/models/policy_session_invalidation.rs @@ -24,7 +24,6 @@ impl PolicySessionInvalidation { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] @@ -44,7 +43,8 @@ mod tests { let json = serde_json::to_string(&model); assert!(json.is_ok()); - let deserialized: Result = serde_json::from_str(&json.unwrap()); + let deserialized: Result = + serde_json::from_str(&json.unwrap()); assert!(deserialized.is_ok()); } } diff --git a/src/models/policy_session_limit.rs b/src/models/policy_session_limit.rs index b1f7c7e..86f066f 100644 --- a/src/models/policy_session_limit.rs +++ b/src/models/policy_session_limit.rs @@ -25,7 +25,6 @@ impl PolicySessionLimit { pub fn total(&self) -> &i64 { &self.total } - } #[cfg(test)] diff --git a/src/models/policy_user_limit.rs b/src/models/policy_user_limit.rs index 5728c92..4515afd 100644 --- a/src/models/policy_user_limit.rs +++ b/src/models/policy_user_limit.rs @@ -25,7 +25,6 @@ impl PolicyUserLimit { pub fn total(&self) -> &i64 { &self.total } - } #[cfg(test)] diff --git a/src/models/postgres_extension.rs b/src/models/postgres_extension.rs new file mode 100644 index 0000000..6fa2b95 --- /dev/null +++ b/src/models/postgres_extension.rs @@ -0,0 +1,67 @@ +//! PostgresExtension model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// Postgres extension +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct PostgresExtension { + /// Extension key used with CREATE EXTENSION. + #[serde(rename = "key")] + pub key: String, + /// Human-readable extension name. + #[serde(rename = "name")] + pub name: String, + /// Short description of what the extension provides. + #[serde(rename = "description")] + pub description: String, + /// Category the extension belongs to. + #[serde(rename = "category")] + pub category: String, +} + +impl PostgresExtension { + /// Get key + pub fn key(&self) -> &String { + &self.key + } + + /// Get name + pub fn name(&self) -> &String { + &self.name + } + + /// Get description + pub fn description(&self) -> &String { + &self.description + } + + /// Get category + pub fn category(&self) -> &String { + &self.category + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_postgres_extension_creation() { + let _model = ::default(); + let _ = _model.key(); + let _ = _model.name(); + let _ = _model.description(); + let _ = _model.category(); + } + + #[test] + fn test_postgres_extension_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/preferences.rs b/src/models/preferences.rs index 5444ff3..25d56e7 100644 --- a/src/models/preferences.rs +++ b/src/models/preferences.rs @@ -7,15 +7,14 @@ use std::collections::HashMap; #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(test, derive(Default))] pub struct Preferences { - #[serde(flatten)] pub data: HashMap, } impl Preferences { - pub fn get(&self, key: &str) -> Option { - self.data.get(key) + self.data + .get(key) .and_then(|v| serde_json::from_value(v.clone()).ok()) } diff --git a/src/models/presence.rs b/src/models/presence.rs index 39331e6..5ed34d4 100644 --- a/src/models/presence.rs +++ b/src/models/presence.rs @@ -102,7 +102,6 @@ impl Presence { pub fn metadata(&self) -> Option<&serde_json::Value> { self.metadata.as_ref() } - } #[cfg(test)] diff --git a/src/models/presence_list.rs b/src/models/presence_list.rs index 86f431d..0257bf7 100644 --- a/src/models/presence_list.rs +++ b/src/models/presence_list.rs @@ -24,7 +24,6 @@ impl PresenceList { pub fn presences(&self) -> &Vec { &self.presences } - } #[cfg(test)] diff --git a/src/models/program.rs b/src/models/program.rs index a0ca092..588d509 100644 --- a/src/models/program.rs +++ b/src/models/program.rs @@ -80,7 +80,6 @@ impl Program { pub fn billing_plan_id(&self) -> &String { &self.billing_plan_id } - } #[cfg(test)] diff --git a/src/models/project.rs b/src/models/project.rs index 19451bd..40a9565 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -92,7 +92,8 @@ pub struct Project { pub console_accessed_at: String, /// Whether WAF enforcement is enabled for the project. #[serde(rename = "wafEnabled")] - pub waf_enabled: bool, + #[serde(skip_serializing_if = "Option::is_none")] + pub waf_enabled: Option, /// Billing limits reached #[serde(rename = "billingLimits")] #[serde(skip_serializing_if = "Option::is_none")] @@ -312,9 +313,15 @@ impl Project { &self.console_accessed_at } + /// Set waf_enabled + pub fn set_waf_enabled(mut self, waf_enabled: bool) -> Self { + self.waf_enabled = Some(waf_enabled); + self + } + /// Get waf_enabled - pub fn waf_enabled(&self) -> &bool { - &self.waf_enabled + pub fn waf_enabled(&self) -> Option<&bool> { + self.waf_enabled.as_ref() } /// Set billing_limits @@ -340,7 +347,10 @@ impl Project { } /// Set o_auth2_server_authorization_url - pub fn set_o_auth2_server_authorization_url(mut self, o_auth2_server_authorization_url: String) -> Self { + pub fn set_o_auth2_server_authorization_url( + mut self, + o_auth2_server_authorization_url: String, + ) -> Self { self.o_auth2_server_authorization_url = Some(o_auth2_server_authorization_url); self } @@ -362,7 +372,10 @@ impl Project { } /// Set o_auth2_server_default_scopes - pub fn set_o_auth2_server_default_scopes(mut self, o_auth2_server_default_scopes: Vec) -> Self { + pub fn set_o_auth2_server_default_scopes( + mut self, + o_auth2_server_default_scopes: Vec, + ) -> Self { self.o_auth2_server_default_scopes = Some(o_auth2_server_default_scopes); self } @@ -373,7 +386,10 @@ impl Project { } /// Set o_auth2_server_installation_scopes - pub fn set_o_auth2_server_installation_scopes(mut self, o_auth2_server_installation_scopes: Vec) -> Self { + pub fn set_o_auth2_server_installation_scopes( + mut self, + o_auth2_server_installation_scopes: Vec, + ) -> Self { self.o_auth2_server_installation_scopes = Some(o_auth2_server_installation_scopes); self } @@ -384,8 +400,12 @@ impl Project { } /// Set o_auth2_server_authorization_details_types - pub fn set_o_auth2_server_authorization_details_types(mut self, o_auth2_server_authorization_details_types: Vec) -> Self { - self.o_auth2_server_authorization_details_types = Some(o_auth2_server_authorization_details_types); + pub fn set_o_auth2_server_authorization_details_types( + mut self, + o_auth2_server_authorization_details_types: Vec, + ) -> Self { + self.o_auth2_server_authorization_details_types = + Some(o_auth2_server_authorization_details_types); self } @@ -395,7 +415,10 @@ impl Project { } /// Set o_auth2_server_access_token_duration - pub fn set_o_auth2_server_access_token_duration(mut self, o_auth2_server_access_token_duration: i64) -> Self { + pub fn set_o_auth2_server_access_token_duration( + mut self, + o_auth2_server_access_token_duration: i64, + ) -> Self { self.o_auth2_server_access_token_duration = Some(o_auth2_server_access_token_duration); self } @@ -406,7 +429,10 @@ impl Project { } /// Set o_auth2_server_refresh_token_duration - pub fn set_o_auth2_server_refresh_token_duration(mut self, o_auth2_server_refresh_token_duration: i64) -> Self { + pub fn set_o_auth2_server_refresh_token_duration( + mut self, + o_auth2_server_refresh_token_duration: i64, + ) -> Self { self.o_auth2_server_refresh_token_duration = Some(o_auth2_server_refresh_token_duration); self } @@ -417,8 +443,12 @@ impl Project { } /// Set o_auth2_server_public_access_token_duration - pub fn set_o_auth2_server_public_access_token_duration(mut self, o_auth2_server_public_access_token_duration: i64) -> Self { - self.o_auth2_server_public_access_token_duration = Some(o_auth2_server_public_access_token_duration); + pub fn set_o_auth2_server_public_access_token_duration( + mut self, + o_auth2_server_public_access_token_duration: i64, + ) -> Self { + self.o_auth2_server_public_access_token_duration = + Some(o_auth2_server_public_access_token_duration); self } @@ -428,8 +458,12 @@ impl Project { } /// Set o_auth2_server_public_refresh_token_duration - pub fn set_o_auth2_server_public_refresh_token_duration(mut self, o_auth2_server_public_refresh_token_duration: i64) -> Self { - self.o_auth2_server_public_refresh_token_duration = Some(o_auth2_server_public_refresh_token_duration); + pub fn set_o_auth2_server_public_refresh_token_duration( + mut self, + o_auth2_server_public_refresh_token_duration: i64, + ) -> Self { + self.o_auth2_server_public_refresh_token_duration = + Some(o_auth2_server_public_refresh_token_duration); self } @@ -439,18 +473,26 @@ impl Project { } /// Set o_auth2_server_installation_access_token_duration - pub fn set_o_auth2_server_installation_access_token_duration(mut self, o_auth2_server_installation_access_token_duration: i64) -> Self { - self.o_auth2_server_installation_access_token_duration = Some(o_auth2_server_installation_access_token_duration); + pub fn set_o_auth2_server_installation_access_token_duration( + mut self, + o_auth2_server_installation_access_token_duration: i64, + ) -> Self { + self.o_auth2_server_installation_access_token_duration = + Some(o_auth2_server_installation_access_token_duration); self } /// Get o_auth2_server_installation_access_token_duration pub fn o_auth2_server_installation_access_token_duration(&self) -> Option<&i64> { - self.o_auth2_server_installation_access_token_duration.as_ref() + self.o_auth2_server_installation_access_token_duration + .as_ref() } /// Set o_auth2_server_confidential_pkce - pub fn set_o_auth2_server_confidential_pkce(mut self, o_auth2_server_confidential_pkce: bool) -> Self { + pub fn set_o_auth2_server_confidential_pkce( + mut self, + o_auth2_server_confidential_pkce: bool, + ) -> Self { self.o_auth2_server_confidential_pkce = Some(o_auth2_server_confidential_pkce); self } @@ -461,7 +503,10 @@ impl Project { } /// Set o_auth2_server_verification_url - pub fn set_o_auth2_server_verification_url(mut self, o_auth2_server_verification_url: String) -> Self { + pub fn set_o_auth2_server_verification_url( + mut self, + o_auth2_server_verification_url: String, + ) -> Self { self.o_auth2_server_verification_url = Some(o_auth2_server_verification_url); self } @@ -472,7 +517,10 @@ impl Project { } /// Set o_auth2_server_user_code_length - pub fn set_o_auth2_server_user_code_length(mut self, o_auth2_server_user_code_length: i64) -> Self { + pub fn set_o_auth2_server_user_code_length( + mut self, + o_auth2_server_user_code_length: i64, + ) -> Self { self.o_auth2_server_user_code_length = Some(o_auth2_server_user_code_length); self } @@ -483,7 +531,10 @@ impl Project { } /// Set o_auth2_server_user_code_format - pub fn set_o_auth2_server_user_code_format(mut self, o_auth2_server_user_code_format: String) -> Self { + pub fn set_o_auth2_server_user_code_format( + mut self, + o_auth2_server_user_code_format: String, + ) -> Self { self.o_auth2_server_user_code_format = Some(o_auth2_server_user_code_format); self } @@ -494,7 +545,10 @@ impl Project { } /// Set o_auth2_server_device_code_duration - pub fn set_o_auth2_server_device_code_duration(mut self, o_auth2_server_device_code_duration: i64) -> Self { + pub fn set_o_auth2_server_device_code_duration( + mut self, + o_auth2_server_device_code_duration: i64, + ) -> Self { self.o_auth2_server_device_code_duration = Some(o_auth2_server_device_code_duration); self } @@ -505,7 +559,10 @@ impl Project { } /// Set o_auth2_server_discovery_url - pub fn set_o_auth2_server_discovery_url(mut self, o_auth2_server_discovery_url: String) -> Self { + pub fn set_o_auth2_server_discovery_url( + mut self, + o_auth2_server_discovery_url: String, + ) -> Self { self.o_auth2_server_discovery_url = Some(o_auth2_server_discovery_url); self } @@ -514,7 +571,6 @@ impl Project { pub fn o_auth2_server_discovery_url(&self) -> Option<&String> { self.o_auth2_server_discovery_url.as_ref() } - } #[cfg(test)] @@ -551,7 +607,6 @@ mod tests { let _ = _model.protocols(); let _ = _model.blocks(); let _ = _model.console_accessed_at(); - let _ = _model.waf_enabled(); } #[test] diff --git a/src/models/project_auth_method.rs b/src/models/project_auth_method.rs index 3462e90..e8428f1 100644 --- a/src/models/project_auth_method.rs +++ b/src/models/project_auth_method.rs @@ -24,7 +24,6 @@ impl ProjectAuthMethod { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/project_list.rs b/src/models/project_list.rs index f5a92f1..9bcda60 100644 --- a/src/models/project_list.rs +++ b/src/models/project_list.rs @@ -24,7 +24,6 @@ impl ProjectList { pub fn projects(&self) -> &Vec { &self.projects } - } #[cfg(test)] diff --git a/src/models/project_protocol.rs b/src/models/project_protocol.rs index 10cf3d9..a8bd9e1 100644 --- a/src/models/project_protocol.rs +++ b/src/models/project_protocol.rs @@ -24,7 +24,6 @@ impl ProjectProtocol { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/project_service.rs b/src/models/project_service.rs index 1818e52..4d94d38 100644 --- a/src/models/project_service.rs +++ b/src/models/project_service.rs @@ -24,7 +24,6 @@ impl ProjectService { pub fn enabled(&self) -> &bool { &self.enabled } - } #[cfg(test)] diff --git a/src/models/provider.rs b/src/models/provider.rs index 077450f..6da6a12 100644 --- a/src/models/provider.rs +++ b/src/models/provider.rs @@ -87,7 +87,6 @@ impl Provider { pub fn options(&self) -> Option<&serde_json::Value> { self.options.as_ref() } - } #[cfg(test)] diff --git a/src/models/provider_list.rs b/src/models/provider_list.rs index cc36da7..3d9c5c9 100644 --- a/src/models/provider_list.rs +++ b/src/models/provider_list.rs @@ -24,7 +24,6 @@ impl ProviderList { pub fn providers(&self) -> &Vec { &self.providers } - } #[cfg(test)] diff --git a/src/models/proxy_invalidation.rs b/src/models/proxy_invalidation.rs index 5e876d3..eaec944 100644 --- a/src/models/proxy_invalidation.rs +++ b/src/models/proxy_invalidation.rs @@ -41,7 +41,6 @@ impl ProxyInvalidation { pub fn status(&self) -> &String { &self.status } - } #[cfg(test)] diff --git a/src/models/proxy_rule.rs b/src/models/proxy_rule.rs index c66d568..1082f77 100644 --- a/src/models/proxy_rule.rs +++ b/src/models/proxy_rule.rs @@ -107,13 +107,18 @@ impl ProxyRule { } /// Set deployment_resource_type - pub fn set_deployment_resource_type(mut self, deployment_resource_type: crate::enums::ProxyRuleDeploymentResourceType) -> Self { + pub fn set_deployment_resource_type( + mut self, + deployment_resource_type: crate::enums::ProxyRuleDeploymentResourceType, + ) -> Self { self.deployment_resource_type = Some(deployment_resource_type); self } /// Get deployment_resource_type - pub fn deployment_resource_type(&self) -> Option<&crate::enums::ProxyRuleDeploymentResourceType> { + pub fn deployment_resource_type( + &self, + ) -> Option<&crate::enums::ProxyRuleDeploymentResourceType> { self.deployment_resource_type.as_ref() } @@ -141,7 +146,6 @@ impl ProxyRule { pub fn renew_at(&self) -> &String { &self.renew_at } - } #[cfg(test)] diff --git a/src/models/proxy_rule_list.rs b/src/models/proxy_rule_list.rs index 3226ff9..ddd137d 100644 --- a/src/models/proxy_rule_list.rs +++ b/src/models/proxy_rule_list.rs @@ -24,7 +24,6 @@ impl ProxyRuleList { pub fn rules(&self) -> &Vec { &self.rules } - } #[cfg(test)] diff --git a/src/models/report.rs b/src/models/report.rs index 8808dce..4f43770 100644 --- a/src/models/report.rs +++ b/src/models/report.rs @@ -113,7 +113,6 @@ impl Report { pub fn analyzed_at(&self) -> Option<&String> { self.analyzed_at.as_ref() } - } #[cfg(test)] diff --git a/src/models/report_list.rs b/src/models/report_list.rs index 1596186..81b4995 100644 --- a/src/models/report_list.rs +++ b/src/models/report_list.rs @@ -24,7 +24,6 @@ impl ReportList { pub fn reports(&self) -> &Vec { &self.reports } - } #[cfg(test)] diff --git a/src/models/resource_token.rs b/src/models/resource_token.rs index 9d796e2..2108383 100644 --- a/src/models/resource_token.rs +++ b/src/models/resource_token.rs @@ -65,7 +65,6 @@ impl ResourceToken { pub fn accessed_at(&self) -> &String { &self.accessed_at } - } #[cfg(test)] diff --git a/src/models/resource_token_list.rs b/src/models/resource_token_list.rs index 818755e..af45953 100644 --- a/src/models/resource_token_list.rs +++ b/src/models/resource_token_list.rs @@ -24,7 +24,6 @@ impl ResourceTokenList { pub fn tokens(&self) -> &Vec { &self.tokens } - } #[cfg(test)] diff --git a/src/models/row.rs b/src/models/row.rs index d90bc78..6c50624 100644 --- a/src/models/row.rs +++ b/src/models/row.rs @@ -70,9 +70,9 @@ impl Row { &self.permissions } - pub fn get(&self, key: &str) -> Option { - self.data.get(key) + self.data + .get(key) .and_then(|v| serde_json::from_value(v.clone()).ok()) } diff --git a/src/models/row_list.rs b/src/models/row_list.rs index 28e8091..ff8047e 100644 --- a/src/models/row_list.rs +++ b/src/models/row_list.rs @@ -24,7 +24,6 @@ impl RowList { pub fn rows(&self) -> &Vec { &self.rows } - } #[cfg(test)] diff --git a/src/models/runtime.rs b/src/models/runtime.rs index 3c71b99..71b88a9 100644 --- a/src/models/runtime.rs +++ b/src/models/runtime.rs @@ -72,7 +72,6 @@ impl Runtime { pub fn supports(&self) -> &Vec { &self.supports } - } #[cfg(test)] diff --git a/src/models/runtime_list.rs b/src/models/runtime_list.rs index aa35316..de7e84b 100644 --- a/src/models/runtime_list.rs +++ b/src/models/runtime_list.rs @@ -24,7 +24,6 @@ impl RuntimeList { pub fn runtimes(&self) -> &Vec { &self.runtimes } - } #[cfg(test)] diff --git a/src/models/session.rs b/src/models/session.rs index bcbe1e8..228fc31 100644 --- a/src/models/session.rs +++ b/src/models/session.rs @@ -244,7 +244,6 @@ impl Session { pub fn mfa_updated_at(&self) -> &String { &self.mfa_updated_at } - } #[cfg(test)] diff --git a/src/models/session_list.rs b/src/models/session_list.rs index 8ca8a5b..8e912c5 100644 --- a/src/models/session_list.rs +++ b/src/models/session_list.rs @@ -24,7 +24,6 @@ impl SessionList { pub fn sessions(&self) -> &Vec { &self.sessions } - } #[cfg(test)] diff --git a/src/models/site.rs b/src/models/site.rs index 94f8ded..4cb6f80 100644 --- a/src/models/site.rs +++ b/src/models/site.rs @@ -60,6 +60,9 @@ pub struct Site { /// "building", "ready", and "failed". #[serde(rename = "latestDeploymentStatus")] pub latest_deployment_status: String, + /// Allowed permission scopes. + #[serde(rename = "scopes")] + pub scopes: Vec, /// Site variables. #[serde(rename = "vars")] pub vars: Vec, @@ -202,6 +205,11 @@ impl Site { &self.latest_deployment_status } + /// Get scopes + pub fn scopes(&self) -> &Vec { + &self.scopes + } + /// Get vars pub fn vars(&self) -> &Vec { &self.vars @@ -291,7 +299,6 @@ impl Site { pub fn fallback_file(&self) -> &String { &self.fallback_file } - } #[cfg(test)] @@ -317,6 +324,7 @@ mod tests { let _ = _model.latest_deployment_id(); let _ = _model.latest_deployment_created_at(); let _ = _model.latest_deployment_status(); + let _ = _model.scopes(); let _ = _model.vars(); let _ = _model.timeout(); let _ = _model.install_command(); diff --git a/src/models/site_list.rs b/src/models/site_list.rs index 231833e..1525368 100644 --- a/src/models/site_list.rs +++ b/src/models/site_list.rs @@ -24,7 +24,6 @@ impl SiteList { pub fn sites(&self) -> &Vec { &self.sites } - } #[cfg(test)] diff --git a/src/models/specification.rs b/src/models/specification.rs index 232e52e..1cbb8a2 100644 --- a/src/models/specification.rs +++ b/src/models/specification.rs @@ -40,7 +40,6 @@ impl Specification { pub fn slug(&self) -> &String { &self.slug } - } #[cfg(test)] diff --git a/src/models/specification_list.rs b/src/models/specification_list.rs index 7028fd0..de28440 100644 --- a/src/models/specification_list.rs +++ b/src/models/specification_list.rs @@ -24,7 +24,6 @@ impl SpecificationList { pub fn specifications(&self) -> &Vec { &self.specifications } - } #[cfg(test)] diff --git a/src/models/subscriber.rs b/src/models/subscriber.rs index c4f0f36..00b5d42 100644 --- a/src/models/subscriber.rs +++ b/src/models/subscriber.rs @@ -81,7 +81,6 @@ impl Subscriber { pub fn provider_type(&self) -> &String { &self.provider_type } - } #[cfg(test)] diff --git a/src/models/subscriber_list.rs b/src/models/subscriber_list.rs index 083681d..045c977 100644 --- a/src/models/subscriber_list.rs +++ b/src/models/subscriber_list.rs @@ -24,7 +24,6 @@ impl SubscriberList { pub fn subscribers(&self) -> &Vec { &self.subscribers } - } #[cfg(test)] diff --git a/src/models/table.rs b/src/models/table.rs index 85a02fb..82cb1f0 100644 --- a/src/models/table.rs +++ b/src/models/table.rs @@ -108,7 +108,6 @@ impl Table { pub fn bytes_used(&self) -> &i64 { &self.bytes_used } - } #[cfg(test)] diff --git a/src/models/table_list.rs b/src/models/table_list.rs index 372ea24..73748c1 100644 --- a/src/models/table_list.rs +++ b/src/models/table_list.rs @@ -24,7 +24,6 @@ impl TableList { pub fn tables(&self) -> &Vec { &self.tables } - } #[cfg(test)] diff --git a/src/models/target.rs b/src/models/target.rs index 56edfb2..79d2dc8 100644 --- a/src/models/target.rs +++ b/src/models/target.rs @@ -88,7 +88,6 @@ impl Target { pub fn expired(&self) -> &bool { &self.expired } - } #[cfg(test)] diff --git a/src/models/target_list.rs b/src/models/target_list.rs index 593ca5b..a3edee5 100644 --- a/src/models/target_list.rs +++ b/src/models/target_list.rs @@ -24,7 +24,6 @@ impl TargetList { pub fn targets(&self) -> &Vec { &self.targets } - } #[cfg(test)] diff --git a/src/models/team.rs b/src/models/team.rs index a5eb40f..b951756 100644 --- a/src/models/team.rs +++ b/src/models/team.rs @@ -56,7 +56,6 @@ impl Team { pub fn prefs(&self) -> &crate::models::Preferences { &self.prefs } - } #[cfg(test)] diff --git a/src/models/team_list.rs b/src/models/team_list.rs index fe267bb..d1df58e 100644 --- a/src/models/team_list.rs +++ b/src/models/team_list.rs @@ -24,7 +24,6 @@ impl TeamList { pub fn teams(&self) -> &Vec { &self.teams } - } #[cfg(test)] diff --git a/src/models/token.rs b/src/models/token.rs index e2b1a4f..89f96f4 100644 --- a/src/models/token.rs +++ b/src/models/token.rs @@ -59,7 +59,6 @@ impl Token { pub fn phrase(&self) -> &String { &self.phrase } - } #[cfg(test)] diff --git a/src/models/topic.rs b/src/models/topic.rs index 3dbc2f7..8ca0133 100644 --- a/src/models/topic.rs +++ b/src/models/topic.rs @@ -72,7 +72,6 @@ impl Topic { pub fn subscribe(&self) -> &Vec { &self.subscribe } - } #[cfg(test)] diff --git a/src/models/topic_list.rs b/src/models/topic_list.rs index a5dbbad..824d84b 100644 --- a/src/models/topic_list.rs +++ b/src/models/topic_list.rs @@ -24,7 +24,6 @@ impl TopicList { pub fn topics(&self) -> &Vec { &self.topics } - } #[cfg(test)] diff --git a/src/models/transaction.rs b/src/models/transaction.rs index 758bc98..bb2272a 100644 --- a/src/models/transaction.rs +++ b/src/models/transaction.rs @@ -57,7 +57,6 @@ impl Transaction { pub fn expires_at(&self) -> &String { &self.expires_at } - } #[cfg(test)] diff --git a/src/models/transaction_list.rs b/src/models/transaction_list.rs index 12a01d2..29cab9e 100644 --- a/src/models/transaction_list.rs +++ b/src/models/transaction_list.rs @@ -24,7 +24,6 @@ impl TransactionList { pub fn transactions(&self) -> &Vec { &self.transactions } - } #[cfg(test)] diff --git a/src/models/usage_billing_plan.rs b/src/models/usage_billing_plan.rs index 04a480c..ab2c459 100644 --- a/src/models/usage_billing_plan.rs +++ b/src/models/usage_billing_plan.rs @@ -77,7 +77,10 @@ impl UsageBillingPlan { } /// Set realtime_bandwidth - pub fn set_realtime_bandwidth(mut self, realtime_bandwidth: crate::models::AdditionalResource) -> Self { + pub fn set_realtime_bandwidth( + mut self, + realtime_bandwidth: crate::models::AdditionalResource, + ) -> Self { self.realtime_bandwidth = Some(realtime_bandwidth); self } @@ -117,7 +120,6 @@ impl UsageBillingPlan { pub fn credits(&self) -> Option<&crate::models::AdditionalResource> { self.credits.as_ref() } - } #[cfg(test)] diff --git a/src/models/user.rs b/src/models/user.rs index d918850..164c8fb 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -291,7 +291,6 @@ impl User { pub fn impersonator_user_id(&self) -> Option<&String> { self.impersonator_user_id.as_ref() } - } #[cfg(test)] diff --git a/src/models/user_list.rs b/src/models/user_list.rs index 5a39f8f..a6e27f4 100644 --- a/src/models/user_list.rs +++ b/src/models/user_list.rs @@ -24,7 +24,6 @@ impl UserList { pub fn users(&self) -> &Vec { &self.users } - } #[cfg(test)] diff --git a/src/models/variable.rs b/src/models/variable.rs index 3bd1f7d..cadb289 100644 --- a/src/models/variable.rs +++ b/src/models/variable.rs @@ -75,7 +75,6 @@ impl Variable { pub fn resource_id(&self) -> &String { &self.resource_id } - } #[cfg(test)] diff --git a/src/models/variable_list.rs b/src/models/variable_list.rs index e661976..9720690 100644 --- a/src/models/variable_list.rs +++ b/src/models/variable_list.rs @@ -24,7 +24,6 @@ impl VariableList { pub fn variables(&self) -> &Vec { &self.variables } - } #[cfg(test)] diff --git a/src/models/vectorsdb_collection.rs b/src/models/vectorsdb_collection.rs new file mode 100644 index 0000000..f352907 --- /dev/null +++ b/src/models/vectorsdb_collection.rs @@ -0,0 +1,152 @@ +//! VectorsdbCollection model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// VectorsDB Collection +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct VectorsdbCollection { + /// Collection ID. + #[serde(rename = "$id")] + pub id: String, + /// Collection creation date in ISO 8601 format. + #[serde(rename = "$createdAt")] + pub created_at: String, + /// Collection update date in ISO 8601 format. + #[serde(rename = "$updatedAt")] + pub updated_at: String, + /// Collection permissions. [Learn more about + /// permissions](https://appwrite.io/docs/permissions). + #[serde(rename = "$permissions")] + pub permissions: Vec, + /// Database ID. + #[serde(rename = "databaseId")] + pub database_id: String, + /// Collection name. + #[serde(rename = "name")] + pub name: String, + /// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the + /// collection is inaccessible to users, but remains accessible to Server SDKs + /// using API keys. + #[serde(rename = "enabled")] + pub enabled: bool, + /// Whether document-level permissions are enabled. [Learn more about + /// permissions](https://appwrite.io/docs/permissions). + #[serde(rename = "documentSecurity")] + pub document_security: bool, + /// Collection attributes. + #[serde(rename = "attributes")] + pub attributes: Vec, + /// Collection indexes. + #[serde(rename = "indexes")] + pub indexes: Vec, + /// Maximum document size in bytes. Returns 0 when no limit applies. + #[serde(rename = "bytesMax")] + pub bytes_max: i64, + /// Currently used document size in bytes based on defined attributes. + #[serde(rename = "bytesUsed")] + pub bytes_used: i64, + /// Embedding dimension. + #[serde(rename = "dimension")] + pub dimension: i64, +} + +impl VectorsdbCollection { + /// 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 permissions + pub fn permissions(&self) -> &Vec { + &self.permissions + } + + /// Get database_id + pub fn database_id(&self) -> &String { + &self.database_id + } + + /// Get name + pub fn name(&self) -> &String { + &self.name + } + + /// Get enabled + pub fn enabled(&self) -> &bool { + &self.enabled + } + + /// Get document_security + pub fn document_security(&self) -> &bool { + &self.document_security + } + + /// Get attributes + pub fn attributes(&self) -> &Vec { + &self.attributes + } + + /// Get indexes + pub fn indexes(&self) -> &Vec { + &self.indexes + } + + /// Get bytes_max + pub fn bytes_max(&self) -> &i64 { + &self.bytes_max + } + + /// Get bytes_used + pub fn bytes_used(&self) -> &i64 { + &self.bytes_used + } + + /// Get dimension + pub fn dimension(&self) -> &i64 { + &self.dimension + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_vectorsdb_collection_creation() { + let _model = ::default(); + let _ = _model.id(); + let _ = _model.created_at(); + let _ = _model.updated_at(); + let _ = _model.permissions(); + let _ = _model.database_id(); + let _ = _model.name(); + let _ = _model.enabled(); + let _ = _model.document_security(); + let _ = _model.attributes(); + let _ = _model.indexes(); + let _ = _model.bytes_max(); + let _ = _model.bytes_used(); + let _ = _model.dimension(); + } + + #[test] + fn test_vectorsdb_collection_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/vectorsdb_collection_list.rs b/src/models/vectorsdb_collection_list.rs new file mode 100644 index 0000000..719dfca --- /dev/null +++ b/src/models/vectorsdb_collection_list.rs @@ -0,0 +1,49 @@ +//! VectorsdbCollectionList model for Appwrite SDK + +use serde::{Deserialize, Serialize}; + +/// VectorsDB Collections List +#[derive(Debug, Clone, Serialize, Deserialize)] +#[cfg_attr(test, derive(Default))] +pub struct VectorsdbCollectionList { + /// Total number of collections that matched your query. + #[serde(rename = "total")] + pub total: i64, + /// List of collections. + #[serde(rename = "collections")] + pub collections: Vec, +} + +impl VectorsdbCollectionList { + /// Get total + pub fn total(&self) -> &i64 { + &self.total + } + + /// Get collections + pub fn collections(&self) -> &Vec { + &self.collections + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_vectorsdb_collection_list_creation() { + let _model = ::default(); + let _ = _model.total(); + let _ = _model.collections(); + } + + #[test] + fn test_vectorsdb_collection_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/webhook.rs b/src/models/webhook.rs index b9552a9..5e398a3 100644 --- a/src/models/webhook.rs +++ b/src/models/webhook.rs @@ -113,7 +113,6 @@ impl Webhook { pub fn attempts(&self) -> &i64 { &self.attempts } - } #[cfg(test)] diff --git a/src/models/webhook_list.rs b/src/models/webhook_list.rs index 7437c37..29d04f7 100644 --- a/src/models/webhook_list.rs +++ b/src/models/webhook_list.rs @@ -24,7 +24,6 @@ impl WebhookList { pub fn webhooks(&self) -> &Vec { &self.webhooks } - } #[cfg(test)] diff --git a/src/operator.rs b/src/operator.rs index 263c3ba..c0d6975 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -45,7 +45,7 @@ fn parse_operator(method: &str, values: Vec) -> String { } fn validate_numeric(value: &Value, param_name: &str) { - if !value.is_number() { + if !value.is_number() { panic!("{} must be a number", param_name); } if let Some(num) = value.as_f64() { @@ -254,7 +254,10 @@ mod tests { #[test] fn test_increment_with_max() { - assert_eq!(increment_with_max(5, 100), r#"{"method":"increment","values":[5,100]}"#); + assert_eq!( + increment_with_max(5, 100), + r#"{"method":"increment","values":[5,100]}"# + ); } #[test] @@ -269,7 +272,10 @@ mod tests { #[test] fn test_decrement_with_min() { - assert_eq!(decrement_with_min(3, 0), r#"{"method":"decrement","values":[3,0]}"#); + assert_eq!( + decrement_with_min(3, 0), + r#"{"method":"decrement","values":[3,0]}"# + ); } #[test] @@ -279,7 +285,10 @@ mod tests { #[test] fn test_multiply_with_max() { - assert_eq!(multiply_with_max(3, 1000), r#"{"method":"multiply","values":[3,1000]}"#); + assert_eq!( + multiply_with_max(3, 1000), + r#"{"method":"multiply","values":[3,1000]}"# + ); } #[test] @@ -289,7 +298,10 @@ mod tests { #[test] fn test_divide_with_min() { - assert_eq!(divide_with_min(4, 1), r#"{"method":"divide","values":[4,1]}"#); + assert_eq!( + divide_with_min(4, 1), + r#"{"method":"divide","values":[4,1]}"# + ); } #[test] @@ -304,27 +316,42 @@ mod tests { #[test] fn test_power_with_max() { - assert_eq!(power_with_max(3, 100), r#"{"method":"power","values":[3,100]}"#); + assert_eq!( + power_with_max(3, 100), + r#"{"method":"power","values":[3,100]}"# + ); } #[test] fn test_array_append() { - assert_eq!(array_append(&["item1", "item2"]), r#"{"method":"arrayAppend","values":["item1","item2"]}"#); + assert_eq!( + array_append(&["item1", "item2"]), + r#"{"method":"arrayAppend","values":["item1","item2"]}"# + ); } #[test] fn test_array_prepend() { - assert_eq!(array_prepend(&["first", "second"]), r#"{"method":"arrayPrepend","values":["first","second"]}"#); + assert_eq!( + array_prepend(&["first", "second"]), + r#"{"method":"arrayPrepend","values":["first","second"]}"# + ); } #[test] fn test_array_insert() { - assert_eq!(array_insert(0, "newItem"), r#"{"method":"arrayInsert","values":[0,"newItem"]}"#); + assert_eq!( + array_insert(0, "newItem"), + r#"{"method":"arrayInsert","values":[0,"newItem"]}"# + ); } #[test] fn test_array_remove() { - assert_eq!(array_remove("oldItem"), r#"{"method":"arrayRemove","values":["oldItem"]}"#); + assert_eq!( + array_remove("oldItem"), + r#"{"method":"arrayRemove","values":["oldItem"]}"# + ); } #[test] @@ -334,32 +361,50 @@ mod tests { #[test] fn test_array_intersect() { - assert_eq!(array_intersect(&["a", "b", "c"]), r#"{"method":"arrayIntersect","values":["a","b","c"]}"#); + assert_eq!( + array_intersect(&["a", "b", "c"]), + r#"{"method":"arrayIntersect","values":["a","b","c"]}"# + ); } #[test] fn test_array_diff() { - assert_eq!(array_diff(&["x", "y"]), r#"{"method":"arrayDiff","values":["x","y"]}"#); + assert_eq!( + array_diff(&["x", "y"]), + r#"{"method":"arrayDiff","values":["x","y"]}"# + ); } #[test] fn test_array_filter() { - assert_eq!(array_filter(Condition::Equal), r#"{"method":"arrayFilter","values":["equal",null]}"#); + assert_eq!( + array_filter(Condition::Equal), + r#"{"method":"arrayFilter","values":["equal",null]}"# + ); } #[test] fn test_array_filter_with_value() { - assert_eq!(array_filter_with_value(Condition::Equal, "test"), r#"{"method":"arrayFilter","values":["equal","test"]}"#); + assert_eq!( + array_filter_with_value(Condition::Equal, "test"), + r#"{"method":"arrayFilter","values":["equal","test"]}"# + ); } #[test] fn test_string_concat() { - assert_eq!(string_concat("suffix"), r#"{"method":"stringConcat","values":["suffix"]}"#); + assert_eq!( + string_concat("suffix"), + r#"{"method":"stringConcat","values":["suffix"]}"# + ); } #[test] fn test_string_replace() { - assert_eq!(string_replace("old", "new"), r#"{"method":"stringReplace","values":["old","new"]}"#); + assert_eq!( + string_replace("old", "new"), + r#"{"method":"stringReplace","values":["old","new"]}"# + ); } #[test] diff --git a/src/query.rs b/src/query.rs index 8e5d7ca..a495391 100644 --- a/src/query.rs +++ b/src/query.rs @@ -30,27 +30,51 @@ impl Query { } pub fn equal, V: Into>(attribute: S, value: V) -> Self { - Self::new("equal".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "equal".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn not_equal, V: Into>(attribute: S, value: V) -> Self { - Self::new("notEqual".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "notEqual".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn less_than, V: Into>(attribute: S, value: V) -> Self { - Self::new("lessThan".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "lessThan".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn less_than_equal, V: Into>(attribute: S, value: V) -> Self { - Self::new("lessThanEqual".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "lessThanEqual".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn greater_than, V: Into>(attribute: S, value: V) -> Self { - Self::new("greaterThan".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "greaterThan".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn greater_than_equal, V: Into>(attribute: S, value: V) -> Self { - Self::new("greaterThanEqual".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "greaterThanEqual".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn is_null>(attribute: S) -> Self { @@ -62,28 +86,51 @@ impl Query { } pub fn between, V: Into>(attribute: S, start: V, end: V) -> Self { - Self::new("between".to_string(), Some(attribute.into()), vec![start.into(), end.into()]) + Self::new( + "between".to_string(), + Some(attribute.into()), + vec![start.into(), end.into()], + ) } pub fn starts_with, V: Into>(attribute: S, value: V) -> Self { - Self::new("startsWith".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "startsWith".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn ends_with, V: Into>(attribute: S, value: V) -> Self { - Self::new("endsWith".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "endsWith".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn select, S: Into>(attributes: I) -> Self { - let values: Vec = attributes.into_iter().map(|s| Value::String(s.into())).collect(); + let values: Vec = attributes + .into_iter() + .map(|s| Value::String(s.into())) + .collect(); Self::new("select".to_string(), None, values) } pub fn search, V: Into>(attribute: S, value: V) -> Self { - Self::new("search".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "search".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn not_search, V: Into>(attribute: S, value: V) -> Self { - Self::new("notSearch".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "notSearch".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn order_asc>(attribute: S) -> Self { @@ -99,11 +146,19 @@ impl Query { } pub fn cursor_after>(document_id: S) -> Self { - Self::new("cursorAfter".to_string(), None, vec![Value::String(document_id.into())]) + Self::new( + "cursorAfter".to_string(), + None, + vec![Value::String(document_id.into())], + ) } pub fn cursor_before>(document_id: S) -> Self { - Self::new("cursorBefore".to_string(), None, vec![Value::String(document_id.into())]) + Self::new( + "cursorBefore".to_string(), + None, + vec![Value::String(document_id.into())], + ) } pub fn limit(value: u32) -> Self { @@ -111,35 +166,67 @@ impl Query { } pub fn offset(value: u32) -> Self { - Self::new("offset".to_string(), None, vec![Value::Number(value.into())]) + Self::new( + "offset".to_string(), + None, + vec![Value::Number(value.into())], + ) } pub fn contains, V: Into>(attribute: S, value: V) -> Self { - Self::new("contains".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "contains".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn contains_any, V: Into>(attribute: S, values: Vec) -> Self { - Self::new("containsAny".to_string(), Some(attribute.into()), values.into_iter().map(|v| v.into()).collect()) + Self::new( + "containsAny".to_string(), + Some(attribute.into()), + values.into_iter().map(|v| v.into()).collect(), + ) } pub fn contains_all, V: Into>(attribute: S, values: Vec) -> Self { - Self::new("containsAll".to_string(), Some(attribute.into()), values.into_iter().map(|v| v.into()).collect()) + Self::new( + "containsAll".to_string(), + Some(attribute.into()), + values.into_iter().map(|v| v.into()).collect(), + ) } pub fn not_contains, V: Into>(attribute: S, value: V) -> Self { - Self::new("notContains".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "notContains".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn not_between, V: Into>(attribute: S, start: V, end: V) -> Self { - Self::new("notBetween".to_string(), Some(attribute.into()), vec![start.into(), end.into()]) + Self::new( + "notBetween".to_string(), + Some(attribute.into()), + vec![start.into(), end.into()], + ) } pub fn not_starts_with, V: Into>(attribute: S, value: V) -> Self { - Self::new("notStartsWith".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "notStartsWith".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn not_ends_with, V: Into>(attribute: S, value: V) -> Self { - Self::new("notEndsWith".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "notEndsWith".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn created_before>(value: V) -> Self { @@ -166,68 +253,148 @@ impl Query { Self::between("$updatedAt", start, end) } - pub fn distance_equal, V: Into>(attribute: S, values: V, distance: impl Into, meters: bool) -> Self { + pub fn distance_equal, V: Into>( + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { let params = Value::Array(vec![values.into(), distance.into(), Value::Bool(meters)]); - Self::new("distanceEqual".to_string(), Some(attribute.into()), vec![params]) - } - - pub fn distance_not_equal, V: Into>(attribute: S, values: V, distance: impl Into, meters: bool) -> Self { + Self::new( + "distanceEqual".to_string(), + Some(attribute.into()), + vec![params], + ) + } + + pub fn distance_not_equal, V: Into>( + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { let params = Value::Array(vec![values.into(), distance.into(), Value::Bool(meters)]); - Self::new("distanceNotEqual".to_string(), Some(attribute.into()), vec![params]) - } - - pub fn distance_greater_than, V: Into>(attribute: S, values: V, distance: impl Into, meters: bool) -> Self { + Self::new( + "distanceNotEqual".to_string(), + Some(attribute.into()), + vec![params], + ) + } + + pub fn distance_greater_than, V: Into>( + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { let params = Value::Array(vec![values.into(), distance.into(), Value::Bool(meters)]); - Self::new("distanceGreaterThan".to_string(), Some(attribute.into()), vec![params]) - } - - pub fn distance_less_than, V: Into>(attribute: S, values: V, distance: impl Into, meters: bool) -> Self { + Self::new( + "distanceGreaterThan".to_string(), + Some(attribute.into()), + vec![params], + ) + } + + pub fn distance_less_than, V: Into>( + attribute: S, + values: V, + distance: impl Into, + meters: bool, + ) -> Self { let params = Value::Array(vec![values.into(), distance.into(), Value::Bool(meters)]); - Self::new("distanceLessThan".to_string(), Some(attribute.into()), vec![params]) + Self::new( + "distanceLessThan".to_string(), + Some(attribute.into()), + vec![params], + ) } pub fn vector_dot, V: Into>(attribute: S, vector: V) -> Self { - Self::new("vectorDot".to_string(), Some(attribute.into()), vec![vector.into()]) + Self::new( + "vectorDot".to_string(), + Some(attribute.into()), + vec![vector.into()], + ) } pub fn vector_cosine, V: Into>(attribute: S, vector: V) -> Self { - Self::new("vectorCosine".to_string(), Some(attribute.into()), vec![vector.into()]) + Self::new( + "vectorCosine".to_string(), + Some(attribute.into()), + vec![vector.into()], + ) } pub fn vector_euclidean, V: Into>(attribute: S, vector: V) -> Self { - Self::new("vectorEuclidean".to_string(), Some(attribute.into()), vec![vector.into()]) + Self::new( + "vectorEuclidean".to_string(), + Some(attribute.into()), + vec![vector.into()], + ) } pub fn intersects, V: Into>(attribute: S, values: V) -> Self { - Self::new("intersects".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "intersects".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn not_intersects, V: Into>(attribute: S, values: V) -> Self { - Self::new("notIntersects".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "notIntersects".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn crosses, V: Into>(attribute: S, values: V) -> Self { - Self::new("crosses".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "crosses".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn not_crosses, V: Into>(attribute: S, values: V) -> Self { - Self::new("notCrosses".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "notCrosses".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn overlaps, V: Into>(attribute: S, values: V) -> Self { - Self::new("overlaps".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "overlaps".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn not_overlaps, V: Into>(attribute: S, values: V) -> Self { - Self::new("notOverlaps".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "notOverlaps".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn touches, V: Into>(attribute: S, values: V) -> Self { - Self::new("touches".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "touches".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn not_touches, V: Into>(attribute: S, values: V) -> Self { - Self::new("notTouches".to_string(), Some(attribute.into()), vec![values.into()]) + Self::new( + "notTouches".to_string(), + Some(attribute.into()), + vec![values.into()], + ) } pub fn or(queries: I) -> Self @@ -255,15 +422,27 @@ impl Query { } pub fn regex, V: Into>(attribute: S, value: V) -> Self { - Self::new("regex".to_string(), Some(attribute.into()), Self::to_array(value.into())) + Self::new( + "regex".to_string(), + Some(attribute.into()), + Self::to_array(value.into()), + ) } pub fn exists>(attributes: Vec) -> Self { - Self::new("exists".to_string(), None, attributes.into_iter().map(|v| v.into()).collect()) + Self::new( + "exists".to_string(), + None, + attributes.into_iter().map(|v| v.into()).collect(), + ) } pub fn not_exists>(attributes: Vec) -> Self { - Self::new("notExists".to_string(), None, attributes.into_iter().map(|v| v.into()).collect()) + Self::new( + "notExists".to_string(), + None, + attributes.into_iter().map(|v| v.into()).collect(), + ) } pub fn elem_match(attribute: S, queries: I) -> Self @@ -298,8 +477,7 @@ impl Query { impl std::fmt::Display for Query { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let json_str = serde_json::to_string(self) - .unwrap_or_else(|_| String::new()); + let json_str = serde_json::to_string(self).unwrap_or_else(|_| String::new()); write!(f, "{}", json_str) } } @@ -425,7 +603,10 @@ mod tests { #[test] fn test_equal_with_array() { let arr = vec!["Movie1", "Movie2"]; - let query = Query::equal("title", Value::Array(arr.iter().map(|s| Value::String(s.to_string())).collect())); + let query = Query::equal( + "title", + Value::Array(arr.iter().map(|s| Value::String(s.to_string())).collect()), + ); let value = query.to_value(); assert_eq!(value["method"], "equal"); assert_eq!(value["attribute"], "title"); @@ -641,7 +822,12 @@ mod tests { #[test] fn test_distance_equal() { - let query = Query::distance_equal("location", Value::Array(vec![Value::from(40.7128), Value::from(-74.0060)]), 5000, true); + let query = Query::distance_equal( + "location", + Value::Array(vec![Value::from(40.7128), Value::from(-74.0060)]), + 5000, + true, + ); let value = query.to_value(); assert_eq!(value["method"], "distanceEqual"); assert_eq!(value["attribute"], "location"); @@ -652,7 +838,12 @@ mod tests { #[test] fn test_distance_not_equal() { - let query = Query::distance_not_equal("location", Value::Array(vec![Value::from(40.7128), Value::from(-74.0060)]), 5000, false); + let query = Query::distance_not_equal( + "location", + Value::Array(vec![Value::from(40.7128), Value::from(-74.0060)]), + 5000, + false, + ); let value = query.to_value(); assert_eq!(value["method"], "distanceNotEqual"); assert_eq!(value["attribute"], "location"); @@ -663,7 +854,12 @@ mod tests { #[test] fn test_distance_greater_than() { - let query = Query::distance_greater_than("location", Value::Array(vec![Value::from(1.0), Value::from(2.0)]), 123, true); + let query = Query::distance_greater_than( + "location", + Value::Array(vec![Value::from(1.0), Value::from(2.0)]), + 123, + true, + ); let value = query.to_value(); assert_eq!(value["method"], "distanceGreaterThan"); assert_eq!(value["attribute"], "location"); @@ -674,7 +870,12 @@ mod tests { #[test] fn test_distance_less_than() { - let query = Query::distance_less_than("location", Value::Array(vec![Value::from(1.0), Value::from(2.0)]), 321, false); + let query = Query::distance_less_than( + "location", + Value::Array(vec![Value::from(1.0), Value::from(2.0)]), + 321, + false, + ); let value = query.to_value(); assert_eq!(value["method"], "distanceLessThan"); assert_eq!(value["attribute"], "location"); @@ -685,7 +886,10 @@ mod tests { #[test] fn test_vector_dot() { - let query = Query::vector_dot("embedding", Value::Array(vec![Value::from(0.1), Value::from(0.2), Value::from(0.3)])); + let query = Query::vector_dot( + "embedding", + Value::Array(vec![Value::from(0.1), Value::from(0.2), Value::from(0.3)]), + ); let value = query.to_value(); assert_eq!(value["method"], "vectorDot"); assert_eq!(value["attribute"], "embedding"); @@ -694,7 +898,10 @@ mod tests { #[test] fn test_vector_cosine() { - let query = Query::vector_cosine("embedding", Value::Array(vec![Value::from(0.1), Value::from(0.2), Value::from(0.3)])); + let query = Query::vector_cosine( + "embedding", + Value::Array(vec![Value::from(0.1), Value::from(0.2), Value::from(0.3)]), + ); let value = query.to_value(); assert_eq!(value["method"], "vectorCosine"); assert_eq!(value["attribute"], "embedding"); @@ -703,7 +910,10 @@ mod tests { #[test] fn test_vector_euclidean() { - let query = Query::vector_euclidean("embedding", Value::Array(vec![Value::from(0.1), Value::from(0.2), Value::from(0.3)])); + let query = Query::vector_euclidean( + "embedding", + Value::Array(vec![Value::from(0.1), Value::from(0.2), Value::from(0.3)]), + ); let value = query.to_value(); assert_eq!(value["method"], "vectorEuclidean"); assert_eq!(value["attribute"], "embedding"); @@ -722,7 +932,8 @@ mod tests { #[test] fn test_not_intersects() { - let query = Query::not_intersects("geo", Value::Array(vec![Value::from(1), Value::from(2)])); + let query = + Query::not_intersects("geo", Value::Array(vec![Value::from(1), Value::from(2)])); let value = query.to_value(); assert_eq!(value["method"], "notIntersects"); assert_eq!(value["attribute"], "geo"); diff --git a/src/services/account.rs b/src/services/account.rs index 46eb3dd..2b88ff2 100644 --- a/src/services/account.rs +++ b/src/services/account.rs @@ -14,7 +14,9 @@ pub struct Account { impl Account { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -22,16 +24,16 @@ impl Account { } /// Get the currently logged in user. - pub async fn get( - &self, - ) -> crate::error::Result { + pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to allow a new user to register a new account in your @@ -61,7 +63,9 @@ impl Account { let path = "/account".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a list of the OAuth2 consents the current user has given to third-party @@ -73,7 +77,10 @@ impl Account { ) -> 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::>())); + 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)); @@ -83,7 +90,9 @@ impl Account { let path = "/account/consents".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get an OAuth2 consent the current user has given to a third-party app by @@ -96,9 +105,13 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/consents/{consentId}".to_string().replace("{consentId}", &consent_id.into().to_string()); + let path = "/account/consents/{consentId}" + .to_string() + .replace("{consentId}", &consent_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an OAuth2 consent by its unique ID. All token families issued under @@ -113,9 +126,13 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/consents/{consentId}".to_string().replace("{consentId}", &consent_id.into().to_string()); + let path = "/account/consents/{consentId}" + .to_string() + .replace("{consentId}", &consent_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of the token families issued under an OAuth2 consent. Each entry @@ -129,7 +146,10 @@ impl Account { ) -> 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::>())); + 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)); @@ -137,9 +157,13 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/consents/{consentId}/tokens".to_string().replace("{consentId}", &consent_id.into().to_string()); + let path = "/account/consents/{consentId}/tokens" + .to_string() + .replace("{consentId}", &consent_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a token family issued under an OAuth2 consent by its unique ID. The @@ -153,9 +177,14 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/consents/{consentId}/tokens/{tokenId}".to_string().replace("{consentId}", &consent_id.into().to_string()).replace("{tokenId}", &token_id.into().to_string()); + let path = "/account/consents/{consentId}/tokens/{tokenId}" + .to_string() + .replace("{consentId}", &consent_id.into().to_string()) + .replace("{tokenId}", &token_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a token family issued under an OAuth2 consent by its unique ID. The @@ -171,9 +200,14 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/consents/{consentId}/tokens/{tokenId}".to_string().replace("{consentId}", &consent_id.into().to_string()).replace("{tokenId}", &token_id.into().to_string()); + let path = "/account/consents/{consentId}/tokens/{tokenId}" + .to_string() + .replace("{consentId}", &consent_id.into().to_string()) + .replace("{tokenId}", &token_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update currently logged in user account email address. After changing user @@ -197,7 +231,9 @@ impl Account { let path = "/account/email".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get the list of identities for the currently logged in user. @@ -208,7 +244,10 @@ impl Account { ) -> 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::>())); + 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)); @@ -218,7 +257,9 @@ impl Account { let path = "/account/identities".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an identity by its unique ID. @@ -230,9 +271,13 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/account/identities/{identityId}".to_string().replace("{identityId}", &identity_id.into().to_string()); + let path = "/account/identities/{identityId}" + .to_string() + .replace("{identityId}", &identity_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get the list of latest security activity logs for the currently logged in @@ -244,7 +289,10 @@ impl Account { ) -> 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::>())); + 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)); @@ -254,14 +302,13 @@ impl Account { let path = "/account/logs".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Enable or disable MFA on an account. - pub async fn update_mfa( - &self, - mfa: bool, - ) -> crate::error::Result { + pub async fn update_mfa(&self, mfa: bool) -> crate::error::Result { let mut params = HashMap::new(); params.insert("mfa".to_string(), json!(mfa)); let mut api_headers = HashMap::new(); @@ -270,7 +317,9 @@ impl Account { let path = "/account/mfa".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Add an authenticator app to be used as an MFA factor. Verify the @@ -286,9 +335,13 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/mfa/authenticators/{type}".to_string().replace("{type}", &r#type.to_string()); + let path = "/account/mfa/authenticators/{type}" + .to_string() + .replace("{type}", &r#type.to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Verify an authenticator app after adding it using the [add @@ -305,9 +358,13 @@ impl Account { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/mfa/authenticators/{type}".to_string().replace("{type}", &r#type.to_string()); + let path = "/account/mfa/authenticators/{type}" + .to_string() + .replace("{type}", &r#type.to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete an authenticator for a user by ID. @@ -319,9 +376,13 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/account/mfa/authenticators/{type}".to_string().replace("{type}", &r#type.to_string()); + let path = "/account/mfa/authenticators/{type}" + .to_string() + .replace("{type}", &r#type.to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Begin the process of MFA verification after sign-in. Finish the flow with @@ -339,7 +400,9 @@ impl Account { let path = "/account/mfa/challenges".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -361,20 +424,22 @@ impl Account { let path = "/account/mfa/challenges".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// List the factors available on the account to be used as a MFA challange. - pub async fn list_mfa_factors( - &self, - ) -> crate::error::Result { + pub async fn list_mfa_factors(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/mfa/factors".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get recovery codes that can be used as backup for MFA flow. Before getting @@ -390,7 +455,9 @@ impl Account { let path = "/account/mfa/recovery-codes".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Generate recovery codes as backup for MFA flow. It's recommended to @@ -408,7 +475,9 @@ impl Account { let path = "/account/mfa/recovery-codes".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -425,7 +494,9 @@ impl Account { let path = "/account/mfa/recovery-codes".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update currently logged in user account name. @@ -441,7 +512,9 @@ impl Account { let path = "/account/name".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update currently logged in user password. For validation, user is required @@ -463,7 +536,9 @@ impl Account { let path = "/account/password".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the currently logged in user's phone number. After updating the @@ -485,20 +560,22 @@ impl Account { let path = "/account/phone".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get the preferences as a key-value object for the currently logged in user. - pub async fn get_prefs( - &self, - ) -> crate::error::Result { + pub async fn get_prefs(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/prefs".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update currently logged in user account preferences. The object you pass is @@ -516,7 +593,9 @@ impl Account { let path = "/account/prefs".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Sends the user an email with a temporary secret key for password reset. @@ -541,7 +620,9 @@ impl Account { let path = "/account/recovery".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to complete the user account password reset. Both the @@ -549,7 +630,7 @@ impl Account { /// the redirect URL you have provided when sending your request to the [POST /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) /// endpoint. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when @@ -570,35 +651,37 @@ impl Account { let path = "/account/recovery".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + 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 { + pub async fn list_sessions(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/account/sessions".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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<()> { + pub async fn delete_sessions(&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()); let path = "/account/sessions".to_string(); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to allow a new user to register an anonymous account in @@ -608,9 +691,7 @@ impl Account { /// password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) /// or create an [OAuth2 /// session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). - pub async fn create_anonymous_session( - &self, - ) -> crate::error::Result { + pub async fn create_anonymous_session(&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()); @@ -618,12 +699,14 @@ impl Account { let path = "/account/sessions/anonymous".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Allow the user to login into their account by providing a valid email and /// password combination. This route will create a new session for the user. - /// + /// /// 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). @@ -641,7 +724,9 @@ impl Account { let path = "/account/sessions/email".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to create a session from token. Provide the **userId** @@ -661,7 +746,9 @@ impl Account { let path = "/account/sessions/magic-url".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to create a session from token. Provide the **userId** @@ -681,7 +768,9 @@ impl Account { let path = "/account/sessions/phone".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to create a session from token. Provide the **userId** @@ -701,7 +790,9 @@ impl Account { let path = "/account/sessions/token".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to get a logged in user's session using a Session ID. @@ -714,9 +805,13 @@ impl Account { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/account/sessions/{sessionId}".to_string().replace("{sessionId}", &session_id.into().to_string()); + let path = "/account/sessions/{sessionId}" + .to_string() + .replace("{sessionId}", &session_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to extend a session's length. Extending a session is @@ -731,9 +826,13 @@ impl Account { 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/{sessionId}".to_string().replace("{sessionId}", &session_id.into().to_string()); + let path = "/account/sessions/{sessionId}" + .to_string() + .replace("{sessionId}", &session_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Logout the user. Use 'current' as the session ID to logout on this device, @@ -741,25 +840,24 @@ impl Account { /// the user on all devices, use [Delete /// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) /// instead. - pub async fn delete_session( - &self, - session_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_session(&self, session_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/account/sessions/{sessionId}".to_string().replace("{sessionId}", &session_id.into().to_string()); + let path = "/account/sessions/{sessionId}" + .to_string() + .replace("{sessionId}", &session_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Block the currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. To /// completely delete a user, use the Users API instead. - pub async fn update_status( - &self, - ) -> crate::error::Result { + pub async fn update_status(&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()); @@ -767,7 +865,9 @@ impl Account { let path = "/account/status".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Sends the user an email with a secret key for creating a session. If the @@ -779,7 +879,7 @@ impl Account { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's email /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). @@ -801,7 +901,9 @@ impl Account { let path = "/account/tokens/email".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Sends the user an email with a secret key for creating a session. If the @@ -813,7 +915,7 @@ impl Account { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The link sent to the user's email /// address is valid for 1 hour. - /// + /// /// 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). @@ -839,20 +941,22 @@ impl Account { let path = "/account/tokens/magic-url".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Allow the user to login to their account using the OAuth2 provider of their /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - /// + /// /// If authentication succeeds, `userId` and `secret` of a token will be /// appended to the success URL as query parameters. These can be used to /// create a new session using the [Create /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint. - /// + /// /// 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). @@ -871,14 +975,21 @@ impl Account { params.insert("failure".to_string(), json!(value)); } if let Some(value) = scopes { - params.insert("scopes".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "scopes".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "text/html".to_string()); - let path = "/account/tokens/oauth2/{provider}".to_string().replace("{provider}", &provider.to_string()); + let path = "/account/tokens/oauth2/{provider}" + .to_string() + .replace("{provider}", &provider.to_string()); - self.client.call_location(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_location(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Sends the user an SMS with a secret key for creating a session. If the @@ -887,7 +998,7 @@ impl Account { /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. - /// + /// /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). @@ -905,7 +1016,9 @@ impl Account { let path = "/account/tokens/phone".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to send a verification message to your user email address @@ -917,7 +1030,7 @@ impl Account { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when @@ -934,7 +1047,9 @@ impl Account { let path = "/account/verifications/email".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to send a verification message to your user email address @@ -946,7 +1061,7 @@ impl Account { /// parameters. Learn more about how to [complete the verification /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). /// The verification link sent to the user's email address is valid for 7 days. - /// + /// /// Please note that in order to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), /// the only valid redirect URLs are the ones from domains you have set when @@ -963,7 +1078,9 @@ impl Account { let path = "/account/verifications/email".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to complete the user email verification process. Use both @@ -984,7 +1101,9 @@ impl Account { let path = "/account/verifications/email".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to complete the user email verification process. Use both @@ -1005,7 +1124,9 @@ impl Account { let path = "/account/verifications/email".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + 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 @@ -1016,9 +1137,7 @@ impl Account { /// process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). /// The verification code sent to the user's phone number is valid for 15 /// minutes. - pub async fn create_phone_verification( - &self, - ) -> crate::error::Result { + pub async fn create_phone_verification(&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()); @@ -1026,7 +1145,9 @@ impl Account { let path = "/account/verifications/phone".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to complete the user phone verification process. Use the @@ -1047,9 +1168,10 @@ impl Account { let path = "/account/verifications/phone".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Account { diff --git a/src/services/activities.rs b/src/services/activities.rs index b822372..c9017d0 100644 --- a/src/services/activities.rs +++ b/src/services/activities.rs @@ -15,7 +15,9 @@ pub struct Activities { impl Activities { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -29,14 +31,19 @@ impl Activities { ) -> 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::>())); + 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 path = "/activities/events".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get event by ID. @@ -48,11 +55,14 @@ impl Activities { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/activities/events/{eventId}".to_string().replace("{eventId}", &event_id.into().to_string()); + let path = "/activities/events/{eventId}" + .to_string() + .replace("{eventId}", &event_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Activities { diff --git a/src/services/advisor.rs b/src/services/advisor.rs index c7a6caa..084c5f2 100644 --- a/src/services/advisor.rs +++ b/src/services/advisor.rs @@ -15,7 +15,9 @@ pub struct Advisor { impl Advisor { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -31,7 +33,10 @@ impl Advisor { ) -> 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::>())); + 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)); @@ -41,7 +46,9 @@ impl Advisor { let path = "/reports".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get an analyzer report by its unique ID. The response includes the report's @@ -54,24 +61,29 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/reports/{reportId}".to_string().replace("{reportId}", &report_id.into().to_string()); + let path = "/reports/{reportId}" + .to_string() + .replace("{reportId}", &report_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an analyzer report by its unique ID. Nested insights and CTA /// metadata are removed asynchronously by the deletes worker. - pub async fn delete_report( - &self, - report_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_report(&self, report_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/reports/{reportId}".to_string().replace("{reportId}", &report_id.into().to_string()); + let path = "/reports/{reportId}" + .to_string() + .replace("{reportId}", &report_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List the insights produced under a single analyzer report. You can use the @@ -84,7 +96,10 @@ impl Advisor { ) -> 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::>())); + 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)); @@ -92,9 +107,13 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/reports/{reportId}/insights".to_string().replace("{reportId}", &report_id.into().to_string()); + let path = "/reports/{reportId}/insights" + .to_string() + .replace("{reportId}", &report_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get an insight by its unique ID, scoped to its parent report. @@ -107,11 +126,15 @@ impl Advisor { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/reports/{reportId}/insights/{insightId}".to_string().replace("{reportId}", &report_id.into().to_string()).replace("{insightId}", &insight_id.into().to_string()); + let path = "/reports/{reportId}/insights/{insightId}" + .to_string() + .replace("{reportId}", &report_id.into().to_string()) + .replace("{insightId}", &insight_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Advisor { diff --git a/src/services/apps.rs b/src/services/apps.rs index 4ac003f..46c3c4b 100644 --- a/src/services/apps.rs +++ b/src/services/apps.rs @@ -15,7 +15,9 @@ pub struct Apps { impl Apps { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -30,7 +32,10 @@ impl Apps { ) -> 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::>())); + 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)); @@ -40,7 +45,9 @@ impl Apps { let path = "/apps".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new application. @@ -86,16 +93,25 @@ impl Apps { params.insert("termsUrl".to_string(), json!(value)); } if let Some(value) = contacts { - params.insert("contacts".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "contacts".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = tagline { params.insert("tagline".to_string(), json!(value)); } if let Some(value) = tags { - params.insert("tags".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "tags".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = images { - params.insert("images".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "images".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = support_url { params.insert("supportUrl".to_string(), json!(value)); @@ -103,9 +119,18 @@ impl Apps { if let Some(value) = data_deletion_url { params.insert("dataDeletionUrl".to_string(), json!(value)); } - params.insert("redirectUris".to_string(), json!(redirect_uris.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "redirectUris".to_string(), + json!(redirect_uris + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); if let Some(value) = post_logout_redirect_uris { - params.insert("postLogoutRedirectUris".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "postLogoutRedirectUris".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); @@ -125,7 +150,9 @@ impl Apps { let path = "/apps".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List scopes an application can request when installed on a team. @@ -138,34 +165,37 @@ impl Apps { let path = "/apps/scopes/installations".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// List scopes an application can request during the OAuth2 flow. - pub async fn list_o_auth2_scopes( - &self, - ) -> crate::error::Result { + pub async fn list_o_auth2_scopes(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/apps/scopes/oauth2".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get an application by its unique ID. - pub async fn get( - &self, - app_id: impl Into, - ) -> crate::error::Result { + pub async fn get(&self, app_id: impl Into) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update an application by its unique ID. @@ -211,16 +241,25 @@ impl Apps { params.insert("termsUrl".to_string(), json!(value)); } if let Some(value) = contacts { - params.insert("contacts".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "contacts".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = tagline { params.insert("tagline".to_string(), json!(value)); } if let Some(value) = tags { - params.insert("tags".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "tags".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = images { - params.insert("images".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "images".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = support_url { params.insert("supportUrl".to_string(), json!(value)); @@ -232,10 +271,16 @@ impl Apps { params.insert("enabled".to_string(), json!(value)); } if let Some(value) = redirect_uris { - params.insert("redirectUris".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "redirectUris".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = post_logout_redirect_uris { - params.insert("postLogoutRedirectUris".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "postLogoutRedirectUris".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = r#type { params.insert("type".to_string(), json!(value)); @@ -244,7 +289,10 @@ impl Apps { params.insert("deviceFlow".to_string(), json!(value)); } if let Some(value) = installation_scopes { - params.insert("installationScopes".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "installationScopes".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = installation_redirect_url { params.insert("installationRedirectUrl".to_string(), json!(value)); @@ -253,9 +301,13 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete an application by its unique ID. @@ -268,9 +320,13 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List installations of an application. Requires an app key sent in the @@ -284,7 +340,10 @@ impl Apps { ) -> 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::>())); + 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)); @@ -292,9 +351,13 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/installations".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/installations" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get an installation of an application by its unique ID. Requires an app key @@ -309,9 +372,14 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/installations/{installationId}".to_string().replace("{appId}", &app_id.into().to_string()).replace("{installationId}", &installation_id.into().to_string()); + let path = "/apps/{appId}/installations/{installationId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an installation of an application by its unique ID. Requires a @@ -327,9 +395,14 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/installations/{installationId}".to_string().replace("{appId}", &app_id.into().to_string()).replace("{installationId}", &installation_id.into().to_string()); + let path = "/apps/{appId}/installations/{installationId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Create a token for an installation of an application. Requires an app key @@ -350,9 +423,14 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/installations/{installationId}/tokens".to_string().replace("{appId}", &app_id.into().to_string()).replace("{installationId}", &installation_id.into().to_string()); + let path = "/apps/{appId}/installations/{installationId}/tokens" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List app keys for an application. @@ -364,7 +442,10 @@ impl Apps { ) -> 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::>())); + 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)); @@ -372,9 +453,13 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/keys" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new app key for an application. App keys carry no scopes; send one @@ -389,9 +474,13 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/keys" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get an app key by its unique ID. @@ -404,9 +493,14 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys/{keyId}".to_string().replace("{appId}", &app_id.into().to_string()).replace("{keyId}", &key_id.into().to_string()); + let path = "/apps/{appId}/keys/{keyId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an app key by its unique ID. @@ -420,9 +514,14 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/keys/{keyId}".to_string().replace("{appId}", &app_id.into().to_string()).replace("{keyId}", &key_id.into().to_string()); + let path = "/apps/{appId}/keys/{keyId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the labels of an application. Labels are read-only for clients; only @@ -434,14 +533,24 @@ impl Apps { labels: impl IntoIterator>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("labels".to_string(), json!(labels.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "labels".to_string(), + json!(labels + .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 = "/apps/{appId}/labels".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/labels" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// List client secrets for an application. @@ -453,7 +562,10 @@ impl Apps { ) -> 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::>())); + 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)); @@ -461,9 +573,13 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/secrets".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/secrets" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new client secret for an application. @@ -476,9 +592,13 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/secrets".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/secrets" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get an application client secret by its unique ID. @@ -491,9 +611,14 @@ impl Apps { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/secrets/{secretId}".to_string().replace("{appId}", &app_id.into().to_string()).replace("{secretId}", &secret_id.into().to_string()); + let path = "/apps/{appId}/secrets/{secretId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{secretId}", &secret_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an application client secret by its unique ID. @@ -507,9 +632,14 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/secrets/{secretId}".to_string().replace("{appId}", &app_id.into().to_string()).replace("{secretId}", &secret_id.into().to_string()); + let path = "/apps/{appId}/secrets/{secretId}" + .to_string() + .replace("{appId}", &app_id.into().to_string()) + .replace("{secretId}", &secret_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Transfer an application to another team by its unique ID. @@ -524,9 +654,13 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/team".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/team" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Revoke all tokens for an application by its unique ID. @@ -539,11 +673,14 @@ impl Apps { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/apps/{appId}/tokens".to_string().replace("{appId}", &app_id.into().to_string()); + let path = "/apps/{appId}/tokens" + .to_string() + .replace("{appId}", &app_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Apps { diff --git a/src/services/avatars.rs b/src/services/avatars.rs index 9a07d89..d7485e3 100644 --- a/src/services/avatars.rs +++ b/src/services/avatars.rs @@ -15,7 +15,9 @@ pub struct Avatars { impl Avatars { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -27,7 +29,7 @@ impl Avatars { /// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) /// endpoint. Use width, height and quality arguments to change the output /// settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size @@ -52,15 +54,19 @@ impl Avatars { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/png".to_string()); - let path = "/avatars/browsers/{code}".to_string().replace("{code}", &code.to_string()); + let path = "/avatars/browsers/{code}" + .to_string() + .replace("{code}", &code.to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// The credit card endpoint will return you the icon of the credit card /// provider you need. Use width, height and quality arguments to change the /// output settings. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size @@ -85,19 +91,20 @@ impl Avatars { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/png".to_string()); - let path = "/avatars/credit-cards/{code}".to_string().replace("{code}", &code.to_string()); + let path = "/avatars/credit-cards/{code}" + .to_string() + .replace("{code}", &code.to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. - /// + /// /// This endpoint does not follow HTTP redirects. - pub async fn get_favicon( - &self, - url: impl Into, - ) -> crate::error::Result> { + pub async fn get_favicon(&self, url: impl Into) -> crate::error::Result> { let mut params = HashMap::new(); params.insert("url".to_string(), json!(url.into())); let mut api_headers = HashMap::new(); @@ -105,14 +112,16 @@ impl Avatars { let path = "/avatars/favicon".to_string(); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. Country codes /// follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size @@ -137,21 +146,25 @@ impl Avatars { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/png".to_string()); - let path = "/avatars/flags/{code}".to_string().replace("{code}", &code.to_string()); + let path = "/avatars/flags/{code}" + .to_string() + .replace("{code}", &code.to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. - /// + /// /// This endpoint does not follow HTTP redirects. pub async fn get_image( &self, @@ -172,7 +185,9 @@ impl Avatars { let path = "/avatars/image".to_string(); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to show your user initials avatar icon on your website or @@ -180,12 +195,12 @@ impl Avatars { /// email initials. You can also overwrite the user name if you pass the 'name' /// parameter. If no name is given and no user is logged, an empty avatar will /// be returned. - /// + /// /// You can use the color and background params to change the avatar colors. By /// default, a random theme will be selected. The random theme will persist for /// the user's initials when reloading the same theme will always return for /// the same initials. - /// + /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size @@ -215,7 +230,68 @@ impl Avatars { let path = "/avatars/initials".to_string(); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Returns the best available profile photo for a user. The endpoint tries + /// each source in priority order and returns the first successful result: + /// OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in + /// static fallback. + /// + /// The photo resolves for the currently authenticated user unless `userId` + /// points at another user. Passing `emailHash` and/or `name` resolves the + /// avatar from those values alone: the hash is looked up on Gravatar and + /// Libravatar, the name is rendered as initials, and the user's own identity + /// photos, email, and name leave the chain so they never shadow the avatar + /// being asked for. Emails are only ever accepted pre-hashed, so no address + /// ends up in a URL. + #[allow(clippy::too_many_arguments)] + pub async fn get_photo( + &self, + width: Option, + height: Option, + quality: Option, + output: Option<&str>, + rating: Option<&str>, + user_id: Option<&str>, + email_hash: Option<&str>, + name: Option<&str>, + ) -> crate::error::Result> { + let mut params = HashMap::new(); + if let Some(value) = width { + params.insert("width".to_string(), json!(value)); + } + if let Some(value) = height { + params.insert("height".to_string(), json!(value)); + } + if let Some(value) = quality { + params.insert("quality".to_string(), json!(value)); + } + if let Some(value) = output { + params.insert("output".to_string(), json!(value)); + } + if let Some(value) = rating { + params.insert("rating".to_string(), json!(value)); + } + if let Some(value) = user_id { + params.insert("userId".to_string(), json!(value)); + } + if let Some(value) = email_hash { + params.insert("emailHash".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("accept".to_string(), "image/*".to_string()); + + let path = "/avatars/photo".to_string(); + + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Converts a given plain text to a QR code image. You can use the query @@ -243,16 +319,18 @@ impl Avatars { let path = "/avatars/qr".to_string(); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. @@ -344,9 +422,10 @@ impl Avatars { let path = "/avatars/screenshots".to_string(); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Avatars { diff --git a/src/services/backups.rs b/src/services/backups.rs index 4c026c6..3379cb7 100644 --- a/src/services/backups.rs +++ b/src/services/backups.rs @@ -15,7 +15,9 @@ pub struct Backups { impl Backups { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -29,14 +31,19 @@ impl Backups { ) -> 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::>())); + 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 path = "/backups/archives".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new archive asynchronously for a project. @@ -56,7 +63,9 @@ impl Backups { let path = "/backups/archives".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a backup archive using it's ID. @@ -68,9 +77,13 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/backups/archives/{archiveId}".to_string().replace("{archiveId}", &archive_id.into().to_string()); + let path = "/backups/archives/{archiveId}" + .to_string() + .replace("{archiveId}", &archive_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an existing archive for a project. @@ -83,9 +96,13 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/backups/archives/{archiveId}".to_string().replace("{archiveId}", &archive_id.into().to_string()); + let path = "/backups/archives/{archiveId}" + .to_string() + .replace("{archiveId}", &archive_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List all policies for a project. @@ -95,14 +112,19 @@ impl Backups { ) -> 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::>())); + 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 path = "/backups/policies".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new backup policy. @@ -137,7 +159,9 @@ impl Backups { let path = "/backups/policies".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a backup policy using it's ID. @@ -149,9 +173,13 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/backups/policies/{policyId}".to_string().replace("{policyId}", &policy_id.into().to_string()); + let path = "/backups/policies/{policyId}" + .to_string() + .replace("{policyId}", &policy_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update an existing policy using it's ID. @@ -180,9 +208,13 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/backups/policies/{policyId}".to_string().replace("{policyId}", &policy_id.into().to_string()); + let path = "/backups/policies/{policyId}" + .to_string() + .replace("{policyId}", &policy_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a policy using it's ID. @@ -195,26 +227,30 @@ impl Backups { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/backups/policies/{policyId}".to_string().replace("{policyId}", &policy_id.into().to_string()); + let path = "/backups/policies/{policyId}" + .to_string() + .replace("{policyId}", &policy_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Create and trigger a new restoration for a backup on a project. - /// + /// /// For a backup of one database, the restoration resolves its destination /// before it is queued. When `newResourceId` is omitted, the archived database /// is restored in place and its own ID is returned in `options`. Pass a /// different `newResourceId` to restore alongside it as a new database /// instead. - /// + /// /// The restoration migration records the archived database in `resourceId` and /// `resourceType`, and the resolved database in `destinationResourceId` and /// `destinationResourceType`. Database types are stored canonically as /// `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave /// these fields empty because they do not have a single source or destination /// database. - /// + /// /// To list every migration related to one database, use its canonical type in /// a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and /// destination relation pairs: `(resourceType, resourceId)`, @@ -222,7 +258,7 @@ impl Backups { /// destinationResourceId)`. Legacy and TablesDB databases use `database`; the /// operational `resourceType` of a table migration is not rewritten to /// `tablesdb`. - /// + /// /// When restoring a DocumentsDB or VectorsDB database from a dedicated source, /// the restore provisions a fresh dedicated backing database at the source /// database's own specification and lands the data there. An in-place restore @@ -253,7 +289,9 @@ impl Backups { let path = "/backups/restoration".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List all backup restorations for a project. @@ -263,14 +301,19 @@ impl Backups { ) -> 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::>())); + 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 path = "/backups/restorations".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get the current status of a backup restoration. @@ -282,11 +325,14 @@ impl Backups { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/backups/restorations/{restorationId}".to_string().replace("{restorationId}", &restoration_id.into().to_string()); + let path = "/backups/restorations/{restorationId}" + .to_string() + .replace("{restorationId}", &restoration_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Backups { diff --git a/src/services/databases.rs b/src/services/databases.rs index 5bf121f..5d035fc 100644 --- a/src/services/databases.rs +++ b/src/services/databases.rs @@ -15,7 +15,9 @@ pub struct Databases { impl Databases { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -32,7 +34,10 @@ impl Databases { ) -> 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::>())); + 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)); @@ -45,7 +50,9 @@ impl Databases { let path = "/databases".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Database. @@ -67,7 +74,9 @@ impl Databases { let path = "/databases".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List transactions across all databases. @@ -77,14 +86,19 @@ impl Databases { ) -> 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::>())); + 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 path = "/databases/transactions".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new transaction. @@ -102,7 +116,9 @@ impl Databases { let path = "/databases/transactions".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a transaction by its unique ID. @@ -114,9 +130,13 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/transactions/{transactionId}".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/databases/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a transaction, to either commit or roll back its operations. @@ -137,9 +157,13 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/transactions/{transactionId}".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/databases/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a transaction by its unique ID. @@ -151,9 +175,13 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/databases/transactions/{transactionId}".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/databases/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Create multiple operations in a single transaction. @@ -170,9 +198,13 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/transactions/{transactionId}/operations".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/databases/transactions/{transactionId}/operations" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a database by its unique ID. This endpoint response returns a JSON @@ -185,9 +217,13 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/databases/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a database by its unique ID. @@ -208,24 +244,29 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/databases/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/databases/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all collections that belong to the provided databaseId. You @@ -239,7 +280,10 @@ impl Databases { ) -> 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::>())); + 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)); @@ -250,9 +294,13 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/databases/{databaseId}/collections" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Collection. Before using this route, you should create a new @@ -275,7 +323,10 @@ impl Databases { params.insert("collectionId".to_string(), json!(collection_id.into())); params.insert("name".to_string(), json!(name.into())); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = document_security { params.insert("documentSecurity".to_string(), json!(value)); @@ -293,9 +344,13 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/databases/{databaseId}/collections" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a collection by its unique ID. This endpoint response returns a JSON @@ -309,9 +364,14 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a collection by its unique ID. @@ -331,7 +391,10 @@ impl Databases { params.insert("name".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = document_security { params.insert("documentSecurity".to_string(), json!(value)); @@ -346,9 +409,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a collection by its unique ID. Only users with write permissions @@ -362,9 +430,14 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List attributes in the collection. @@ -377,7 +450,10 @@ impl Databases { ) -> 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::>())); + 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)); @@ -385,9 +461,14 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a bigint attribute. Optionally, minimum and maximum values can be @@ -423,9 +504,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a bigint attribute. Changing the `default` value will not update @@ -460,9 +546,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a boolean attribute. @@ -488,9 +580,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a boolean attribute. Changing the `default` value will not update @@ -516,9 +613,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a date time attribute according to the ISO 8601 standard. @@ -544,9 +647,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a date time attribute. Changing the `default` value will not update @@ -572,9 +680,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create an email attribute. @@ -600,9 +714,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an email attribute. Changing the `default` value will not update @@ -628,9 +747,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create an enum attribute. The `elements` param acts as a white-list of @@ -648,7 +773,13 @@ impl Databases { ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("key".to_string(), json!(key.into())); - params.insert("elements".to_string(), json!(elements.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "elements".to_string(), + json!(elements + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); params.insert("required".to_string(), json!(required)); if let Some(value) = default { params.insert("default".to_string(), json!(value)); @@ -660,9 +791,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an enum attribute. Changing the `default` value will not update @@ -679,7 +815,13 @@ impl Databases { new_key: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("elements".to_string(), json!(elements.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "elements".to_string(), + json!(elements + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); params.insert("required".to_string(), json!(required)); if let Some(value) = default { params.insert("default".to_string(), json!(value)); @@ -691,9 +833,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a float attribute. Optionally, minimum and maximum values can be @@ -729,9 +877,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a float attribute. Changing the `default` value will not update @@ -766,9 +919,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create an integer attribute. Optionally, minimum and maximum values can be @@ -804,9 +963,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an integer attribute. Changing the `default` value will not update @@ -841,9 +1005,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create IP address attribute. @@ -869,9 +1039,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an ip attribute. Changing the `default` value will not update @@ -897,9 +1072,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a geometric line attribute. @@ -921,9 +1102,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a line attribute. Changing the `default` value will not update @@ -949,9 +1135,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a longtext attribute. @@ -982,9 +1174,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a longtext attribute. Changing the `default` value will not update @@ -1010,9 +1207,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a mediumtext attribute. @@ -1043,9 +1246,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a mediumtext attribute. Changing the `default` value will not update @@ -1071,9 +1279,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a geometric point attribute. @@ -1095,9 +1309,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a point attribute. Changing the `default` value will not update @@ -1123,9 +1342,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a geometric polygon attribute. @@ -1147,9 +1372,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a polygon attribute. Changing the `default` value will not update @@ -1175,9 +1405,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create relationship attribute. [Learn more about relationship @@ -1195,7 +1431,10 @@ impl Databases { on_delete: Option, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("relatedCollectionId".to_string(), json!(related_collection_id.into())); + params.insert( + "relatedCollectionId".to_string(), + json!(related_collection_id.into()), + ); params.insert("type".to_string(), json!(r#type)); if let Some(value) = two_way { params.insert("twoWay".to_string(), json!(value)); @@ -1213,9 +1452,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update relationship attribute. [Learn more about relationship @@ -1239,9 +1483,16 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = + "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a string attribute. @@ -1274,9 +1525,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a string attribute. Changing the `default` value will not update @@ -1307,9 +1563,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a text attribute. @@ -1340,9 +1602,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a text attribute. Changing the `default` value will not update @@ -1368,9 +1635,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a URL attribute. @@ -1396,9 +1669,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an url attribute. Changing the `default` value will not update @@ -1424,9 +1702,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a varchar attribute. @@ -1459,9 +1743,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a varchar attribute. Changing the `default` value will not update @@ -1492,9 +1781,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get attribute by ID. @@ -1508,9 +1803,15 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Deletes an attribute. @@ -1524,9 +1825,15 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the user's documents in a given collection. You can use @@ -1542,7 +1849,10 @@ impl Databases { ) -> 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::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1556,9 +1866,14 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Document. Before using this route, you should create a new @@ -1578,7 +1893,10 @@ impl Databases { params.insert("documentId".to_string(), json!(document_id.into())); params.insert("data".to_string(), json!(data)); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1587,9 +1905,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create new Documents. Before using this route, you should create a new @@ -1612,9 +1935,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create or update Documents. Before using this route, you should create a @@ -1637,9 +1965,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Update all documents that match your queries, if no queries are submitted @@ -1658,7 +1991,10 @@ impl Databases { params.insert("data".to_string(), json!(value)); } if let Some(value) = queries { - params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1667,9 +2003,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Bulk delete documents using queries, if no queries are passed then all @@ -1683,7 +2024,10 @@ impl Databases { ) -> 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::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1692,9 +2036,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a document by its unique ID. This endpoint response returns a JSON @@ -1709,7 +2058,10 @@ impl Databases { ) -> 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::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1717,9 +2069,15 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{documentId}", &document_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create or update a Document. Before using this route, you should create a @@ -1740,7 +2098,10 @@ impl Databases { params.insert("data".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1749,9 +2110,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{documentId}", &document_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Update a document by its unique ID. Using the patch method you can pass @@ -1770,7 +2137,10 @@ impl Databases { params.insert("data".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1779,9 +2149,15 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{documentId}", &document_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a document by its unique ID. @@ -1799,9 +2175,15 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{documentId}", &document_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Decrement a specific attribute of a document by a given value. @@ -1830,9 +2212,17 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{documentId}", &document_id.into().to_string()).replace("{attribute}", &attribute.into().to_string()); + let path = + "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()) + .replace("{attribute}", &attribute.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Increment a specific attribute of a document by a given value. @@ -1861,9 +2251,17 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{documentId}", &document_id.into().to_string()).replace("{attribute}", &attribute.into().to_string()); + let path = + "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()) + .replace("{attribute}", &attribute.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// List indexes in the collection. @@ -1876,7 +2274,10 @@ impl Databases { ) -> 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::>())); + 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)); @@ -1884,9 +2285,14 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/indexes".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Creates an index on the attributes listed. Your index should include all @@ -1906,7 +2312,13 @@ impl Databases { let mut params = HashMap::new(); params.insert("key".to_string(), json!(key.into())); params.insert("type".to_string(), json!(r#type)); - params.insert("attributes".to_string(), json!(attributes.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "attributes".to_string(), + json!(attributes + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); if let Some(value) = orders { params.insert("orders".to_string(), json!(value)); } @@ -1917,9 +2329,14 @@ impl Databases { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/indexes".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get an index by its unique ID. @@ -1933,9 +2350,15 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an index. @@ -1949,11 +2372,16 @@ impl Databases { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{collectionId}", &collection_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/databases/{databaseId}/collections/{collectionId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Databases { diff --git a/src/services/documents_db.rs b/src/services/documents_db.rs new file mode 100644 index 0000000..d0923d1 --- /dev/null +++ b/src/services/documents_db.rs @@ -0,0 +1,1133 @@ +//! DocumentsDB service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct DocumentsDB { + client: Client, +} + +impl DocumentsDB { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// Get a list of all databases from the current Appwrite project. You can use + /// the search parameter to filter your results. + pub async fn list( + &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 = "/documentsdb".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new Database. + pub async fn create( + &self, + database_id: impl Into, + name: impl Into, + enabled: Option, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("databaseId".to_string(), json!(database_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) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".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 = "/documentsdb".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the dedicated database specifications available on the current plan. + /// Each specification reports its resource limits, pricing, and whether it is + /// enabled for the organization. + pub async fn list_specifications( + &self, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/specifications".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// List transactions across all databases. + pub async fn list_transactions( + &self, + 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 path = "/documentsdb/transactions".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new transaction. + pub async fn create_transaction( + &self, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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 = "/documentsdb/transactions".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a transaction by its unique ID. + pub async fn get_transaction( + &self, + transaction_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a transaction, to either commit or roll back its operations. + pub async fn update_transaction( + &self, + transaction_id: impl Into, + commit: Option, + rollback: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = commit { + params.insert("commit".to_string(), json!(value)); + } + if let Some(value) = rollback { + params.insert("rollback".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 = "/documentsdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a transaction by its unique ID. + pub async fn delete_transaction( + &self, + transaction_id: impl Into, + ) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/documentsdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Create multiple operations in a single transaction. + pub async fn create_operations( + &self, + transaction_id: impl Into, + operations: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = operations { + params.insert("operations".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 = "/documentsdb/transactions/{transactionId}/operations" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a database by its unique ID. This endpoint response returns a JSON + /// object with the database metadata. + pub async fn get( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a database by its unique ID. + pub async fn update( + &self, + database_id: impl Into, + name: impl Into, + enabled: Option, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".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 = "/documentsdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a database by its unique ID. Only API keys with with databases.write + /// scope can delete a database. + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a list of all collections that belong to the provided databaseId. You + /// can use the search parameter to filter your results. + pub async fn list_collections( + &self, + database_id: impl Into, + 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 = "/documentsdb/{databaseId}/collections" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new Collection. Before using this route, you should create a new + /// database resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + #[allow(clippy::too_many_arguments)] + pub async fn create_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + name: impl Into, + permissions: Option>, + document_security: Option, + enabled: Option, + attributes: Option>, + indexes: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("collectionId".to_string(), json!(collection_id.into())); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = document_security { + params.insert("documentSecurity".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = attributes { + params.insert("attributes".to_string(), json!(value)); + } + if let Some(value) = indexes { + params.insert("indexes".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 = "/documentsdb/{databaseId}/collections" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a collection by its unique ID. This endpoint response returns a JSON + /// object with the collection metadata. + pub async fn get_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a collection by its unique ID. + #[allow(clippy::too_many_arguments)] + pub async fn update_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + name: impl Into, + permissions: Option>, + document_security: Option, + enabled: Option, + purge: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = document_security { + params.insert("documentSecurity".to_string(), json!(value)); + } + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = purge { + params.insert("purge".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 = "/documentsdb/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a collection by its unique ID. Only users with write permissions + /// have access to delete this resource. + pub async fn delete_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + ) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a list of all the user's documents in a given collection. You can use + /// the query params to filter your results. + pub async fn list_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + queries: Option>, + transaction_id: Option<&str>, + total: Option, + ttl: 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) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + if let Some(value) = total { + params.insert("total".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("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new Document. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn create_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + data: serde_json::Value, + permissions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("documentId".to_string(), json!(document_id.into())); + params.insert("data".to_string(), json!(data)); + if let Some(value) = permissions { + params.insert( + "permissions".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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Create new Documents. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn create_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + documents: Vec, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("documents".to_string(), json!(documents)); + let mut api_headers = 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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Create or update Documents. Before using this route, you should create a + /// new collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn upsert_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + documents: Vec, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("documents".to_string(), json!(documents)); + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Update all documents that match your queries, if no queries are submitted + /// then all documents are updated. You can pass only specific fields to be + /// updated. + pub async fn update_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + data: Option, + queries: Option>, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = data { + params.insert("data".to_string(), json!(value)); + } + if let Some(value) = queries { + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Bulk delete documents using queries, if no queries are passed then all + /// documents are deleted. + pub async fn delete_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + queries: Option>, + transaction_id: 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) = transaction_id { + params.insert("transactionId".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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a document by its unique ID. This endpoint response returns a JSON + /// object with the document data. + pub async fn get_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + queries: Option>, + transaction_id: 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) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create or update a Document. Before using this route, you should create a + /// new collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn upsert_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + data: Option, + permissions: Option>, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = data { + params.insert("data".to_string(), json!(value)); + } + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a document by its unique ID. Using the patch method you can pass + /// only specific fields that will get updated. + pub async fn update_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + data: Option, + permissions: Option>, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = data { + params.insert("data".to_string(), json!(value)); + } + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a document by its unique ID. + pub async fn delete_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + transaction_id: Option<&str>, + ) -> crate::error::Result<()> { + let mut params = HashMap::new(); + if let Some(value) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Decrement a specific column of a row by a given value. + #[allow(clippy::too_many_arguments)] + pub async fn decrement_document_attribute( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + attribute: impl Into, + value: Option, + min: Option, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = value { + params.insert("value".to_string(), json!(value)); + } + if let Some(value) = min { + params.insert("min".to_string(), json!(value)); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = + "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()) + .replace("{attribute}", &attribute.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Increment a specific column of a row by a given value. + #[allow(clippy::too_many_arguments)] + pub async fn increment_document_attribute( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + attribute: impl Into, + value: Option, + max: Option, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = value { + params.insert("value".to_string(), json!(value)); + } + if let Some(value) = max { + params.insert("max".to_string(), json!(value)); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = + "/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()) + .replace("{attribute}", &attribute.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// List indexes in the collection. + pub async fn list_indexes( + &self, + database_id: impl Into, + collection_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 path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Creates an index on the attributes listed. Your index should include all + /// the attributes you will query in a single request. + /// Attributes can be `key`, `fulltext`, and `unique`. + #[allow(clippy::too_many_arguments)] + pub async fn create_index( + &self, + database_id: impl Into, + collection_id: impl Into, + key: impl Into, + r#type: crate::enums::DocumentsDBIndexType, + attributes: impl IntoIterator>, + orders: Option>, + lengths: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("key".to_string(), json!(key.into())); + params.insert("type".to_string(), json!(r#type)); + params.insert( + "attributes".to_string(), + json!(attributes + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); + if let Some(value) = orders { + params.insert("orders".to_string(), json!(value)); + } + if let Some(value) = lengths { + params.insert("lengths".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 = "/documentsdb/{databaseId}/collections/{collectionId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get index by ID. + pub async fn get_index( + &self, + database_id: impl Into, + collection_id: impl Into, + key: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete an index. + pub async fn delete_index( + &self, + database_id: impl Into, + collection_id: impl Into, + key: impl Into, + ) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Trigger a manual failover for a dedicated database with high availability + /// enabled. Promotes a replica to primary. The failover runs asynchronously; + /// poll the database document for status updates. A database left + /// mid-operation also accepts this call as a repair once nothing is driving + /// the operation it is stuck in. Repairing a failover that did not finish, a + /// `failed` database, a stranded upgrade or migrate, or a stranded compute + /// resize additionally requires `targetReplicaId` to name the member to + /// promote, because the default target may be the member that operation + /// already promoted. + pub async fn create_failover( + &self, + database_id: impl Into, + target_replica_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = target_replica_id { + params.insert("targetReplicaId".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 = "/documentsdb/{databaseId}/failovers" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the lifecycle operations recorded for a dedicated database, newest + /// first. Every provision, update, restore, backup and replication action is + /// recorded here with its outcome, including an attempt that was abandoned + /// because another worker took over the database. + pub async fn list_operations( + &self, + database_id: impl Into, + status: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/operations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get high availability status for a dedicated database. Returns replica + /// statuses, replication lag, and sync mode. + pub async fn get_replicas( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/replicas" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get real-time health and status information for a dedicated database. + /// Returns health status, readiness, uptime, connection info, replica status, + /// and volume information. + pub async fn get_status( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/documentsdb/{databaseId}/status" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for DocumentsDB { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_documents_db_creation() { + let client = Client::new(); + let service = DocumentsDB::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} diff --git a/src/services/embeddings.rs b/src/services/embeddings.rs index 953d5a0..5f2e333 100644 --- a/src/services/embeddings.rs +++ b/src/services/embeddings.rs @@ -13,7 +13,9 @@ pub struct Embeddings { impl Embeddings { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -29,7 +31,10 @@ impl Embeddings { model: Option, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("texts".to_string(), json!(texts.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "texts".to_string(), + json!(texts.into_iter().map(|s| s.into()).collect::>()), + ); if let Some(value) = model { params.insert("model".to_string(), json!(value)); } @@ -39,9 +44,10 @@ impl Embeddings { let path = "/embeddings/text".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Embeddings { diff --git a/src/services/functions.rs b/src/services/functions.rs index 504d346..049c4ca 100644 --- a/src/services/functions.rs +++ b/src/services/functions.rs @@ -15,7 +15,9 @@ pub struct Functions { impl Functions { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -32,7 +34,10 @@ impl Functions { ) -> 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::>())); + 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)); @@ -45,7 +50,9 @@ impl Functions { let path = "/functions".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new function. You can pass a list of @@ -83,10 +90,16 @@ impl Functions { params.insert("name".to_string(), json!(name.into())); params.insert("runtime".to_string(), json!(runtime)); if let Some(value) = execute { - params.insert("execute".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "execute".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = events { - params.insert("events".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "events".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = schedule { params.insert("schedule".to_string(), json!(value)); @@ -125,10 +138,16 @@ impl Functions { params.insert("providerRootDirectory".to_string(), json!(value)); } if let Some(value) = provider_branches { - params.insert("providerBranches".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerBranches".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = provider_paths { - params.insert("providerPaths".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerPaths".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = build_specification { params.insert("buildSpecification".to_string(), json!(value)); @@ -145,20 +164,22 @@ impl Functions { let path = "/functions".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all runtimes that are currently active on your instance. - pub async fn list_runtimes( - &self, - ) -> crate::error::Result { + pub async fn list_runtimes(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/functions/runtimes".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// List allowed function specifications for this instance. @@ -175,7 +196,9 @@ impl Functions { let path = "/functions/specifications".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a function by its unique ID. @@ -187,9 +210,13 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update function by its unique ID. @@ -225,10 +252,16 @@ impl Functions { params.insert("runtime".to_string(), json!(value)); } if let Some(value) = execute { - params.insert("execute".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "execute".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = events { - params.insert("events".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "events".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = schedule { params.insert("schedule".to_string(), json!(value)); @@ -267,10 +300,16 @@ impl Functions { params.insert("providerRootDirectory".to_string(), json!(value)); } if let Some(value) = provider_branches { - params.insert("providerBranches".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerBranches".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = provider_paths { - params.insert("providerPaths".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerPaths".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = build_specification { params.insert("buildSpecification".to_string(), json!(value)); @@ -285,23 +324,28 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a function by its unique ID. - pub async fn delete( - &self, - function_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, function_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the function active deployment. Use this endpoint to switch the code @@ -317,9 +361,13 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployment".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/deployment" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the function's code deployments. You can use the query @@ -333,7 +381,10 @@ impl Functions { ) -> 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::>())); + 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)); @@ -344,20 +395,24 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/deployments" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new function code deployment. Use this endpoint to upload a new /// version of your code function. To execute your newly uploaded code, you'll /// need to update the function's deployment to use your new deployment UID. - /// + /// /// This endpoint accepts a tar.gz file compressed with your code. Make sure to /// include any dependencies your code has within the compressed file. You can /// learn more about code packaging in the [Appwrite Cloud Functions /// tutorial](https://appwrite.io/docs/functions). - /// + /// /// Use the "command" param to set the entrypoint used to execute your code. pub async fn create_deployment( &self, @@ -376,12 +431,19 @@ impl Functions { } params.insert("activate".to_string(), json!(activate)); let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "multipart/form-data".to_string()); + api_headers.insert( + "content-type".to_string(), + "multipart/form-data".to_string(), + ); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/deployments" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.file_upload(&path, Some(api_headers), params, "code", code, None).await + self.client + .file_upload(&path, Some(api_headers), params, "code", code, None) + .await } /// Create a new build for an existing function deployment. This endpoint @@ -404,13 +466,17 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments/duplicate".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/deployments/duplicate" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a deployment based on a template. - /// + /// /// Use this endpoint with combination of /// [listTemplates](https://appwrite.io/docs/products/functions/templates) to /// find the template details. @@ -438,13 +504,17 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments/template".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/deployments/template" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a deployment when a function is connected to VCS. - /// + /// /// This endpoint lets you create deployment from a branch, commit, or a tag. pub async fn create_vcs_deployment( &self, @@ -463,9 +533,13 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments/vcs".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/deployments/vcs" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a function deployment by its unique ID. @@ -478,9 +552,14 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments/{deploymentId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/functions/{functionId}/deployments/{deploymentId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a code deployment by its unique ID. @@ -493,9 +572,14 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments/{deploymentId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/functions/{functionId}/deployments/{deploymentId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a function deployment content by its unique ID. The endpoint response @@ -518,9 +602,14 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); - let path = "/functions/{functionId}/deployments/{deploymentId}/download".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/functions/{functionId}/deployments/{deploymentId}/download" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Cancel an ongoing function deployment build. If the build is already in @@ -538,9 +627,14 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/deployments/{deploymentId}/status".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/functions/{functionId}/deployments/{deploymentId}/status" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the current user function execution logs. You can use the @@ -553,7 +647,10 @@ impl Functions { ) -> 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::>())); + 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)); @@ -561,9 +658,13 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/executions".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/executions" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Trigger a function execution. The returned object will return you the @@ -604,9 +705,13 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/executions".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/executions" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a function execution log by its unique ID. @@ -619,9 +724,14 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/executions/{executionId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{executionId}", &execution_id.into().to_string()); + let path = "/functions/{functionId}/executions/{executionId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{executionId}", &execution_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a function execution by its unique ID. @@ -634,9 +744,14 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/executions/{executionId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{executionId}", &execution_id.into().to_string()); + let path = "/functions/{functionId}/executions/{executionId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{executionId}", &execution_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all variables of a specific function. @@ -648,7 +763,10 @@ impl Functions { ) -> 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::>())); + 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)); @@ -656,9 +774,13 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/variables".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/variables" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new function environment variable. These variables can be accessed @@ -682,9 +804,13 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/variables".to_string().replace("{functionId}", &function_id.into().to_string()); + let path = "/functions/{functionId}/variables" + .to_string() + .replace("{functionId}", &function_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a variable by its unique ID. @@ -697,9 +823,14 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/variables/{variableId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{variableId}", &variable_id.into().to_string()); + let path = "/functions/{functionId}/variables/{variableId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update variable by its unique ID. @@ -725,9 +856,14 @@ impl Functions { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/variables/{variableId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{variableId}", &variable_id.into().to_string()); + let path = "/functions/{functionId}/variables/{variableId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a variable by its unique ID. @@ -740,11 +876,15 @@ impl Functions { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/functions/{functionId}/variables/{variableId}".to_string().replace("{functionId}", &function_id.into().to_string()).replace("{variableId}", &variable_id.into().to_string()); + let path = "/functions/{functionId}/variables/{variableId}" + .to_string() + .replace("{functionId}", &function_id.into().to_string()) + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Functions { diff --git a/src/services/graphql.rs b/src/services/graphql.rs index c7733cb..f011ea8 100644 --- a/src/services/graphql.rs +++ b/src/services/graphql.rs @@ -15,7 +15,9 @@ pub struct Graphql { impl Graphql { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -23,10 +25,7 @@ impl Graphql { } /// Execute a GraphQL mutation. - pub async fn query( - &self, - query: serde_json::Value, - ) -> crate::error::Result { + pub async fn query(&self, query: serde_json::Value) -> crate::error::Result { let mut params = HashMap::new(); params.insert("query".to_string(), json!(query)); let mut api_headers = HashMap::new(); @@ -36,7 +35,9 @@ impl Graphql { let path = "/graphql".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Execute a GraphQL mutation. @@ -53,9 +54,10 @@ impl Graphql { let path = "/graphql/mutation".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Graphql { diff --git a/src/services/locale.rs b/src/services/locale.rs index aa13c87..3653b8f 100644 --- a/src/services/locale.rs +++ b/src/services/locale.rs @@ -15,7 +15,9 @@ pub struct Locale { impl Locale { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -26,119 +28,118 @@ impl Locale { /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. - /// + /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) - pub async fn get( - &self, - ) -> crate::error::Result { + pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_codes(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/codes".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_continents(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/continents".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_countries(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/countries".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_countries_eu(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/countries/eu".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_countries_phones(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/countries/phones".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_currencies(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/currencies".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// 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 { + pub async fn list_languages(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/locale/languages".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Locale { diff --git a/src/services/messaging.rs b/src/services/messaging.rs index afea854..e83e71a 100644 --- a/src/services/messaging.rs +++ b/src/services/messaging.rs @@ -15,7 +15,9 @@ pub struct Messaging { impl Messaging { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -31,7 +33,10 @@ impl Messaging { ) -> 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::>())); + 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)); @@ -44,7 +49,9 @@ impl Messaging { let path = "/messaging/messages".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new email message. @@ -69,22 +76,40 @@ impl Messaging { params.insert("subject".to_string(), json!(subject.into())); params.insert("content".to_string(), json!(content.into())); if let Some(value) = topics { - params.insert("topics".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "topics".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = users { - params.insert("users".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "users".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = targets { - params.insert("targets".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "targets".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = cc { - params.insert("cc".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "cc".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = bcc { - params.insert("bcc".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "bcc".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = attachments { - params.insert("attachments".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "attachments".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = draft { params.insert("draft".to_string(), json!(value)); @@ -101,7 +126,9 @@ impl Messaging { let path = "/messaging/messages/email".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an email message by its unique ID. This endpoint only works on @@ -125,13 +152,22 @@ impl Messaging { ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = topics { - params.insert("topics".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "topics".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = users { - params.insert("users".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "users".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = targets { - params.insert("targets".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "targets".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = subject { params.insert("subject".to_string(), json!(value)); @@ -146,24 +182,37 @@ impl Messaging { params.insert("html".to_string(), json!(value)); } if let Some(value) = cc { - params.insert("cc".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "cc".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = bcc { - params.insert("bcc".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "bcc".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = scheduled_at { params.insert("scheduledAt".to_string(), json!(value)); } if let Some(value) = attachments { - params.insert("attachments".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "attachments".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 = "/messaging/messages/email/{messageId}".to_string().replace("{messageId}", &message_id.into().to_string()); + let path = "/messaging/messages/email/{messageId}" + .to_string() + .replace("{messageId}", &message_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new push notification. @@ -199,13 +248,22 @@ impl Messaging { params.insert("body".to_string(), json!(value)); } if let Some(value) = topics { - params.insert("topics".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "topics".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = users { - params.insert("users".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "users".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = targets { - params.insert("targets".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "targets".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = data { params.insert("data".to_string(), json!(value)); @@ -252,7 +310,9 @@ impl Messaging { let path = "/messaging/messages/push".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a push notification by its unique ID. This endpoint only works on @@ -283,13 +343,22 @@ impl Messaging { ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = topics { - params.insert("topics".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "topics".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = users { - params.insert("users".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "users".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = targets { - params.insert("targets".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "targets".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = title { params.insert("title".to_string(), json!(value)); @@ -340,9 +409,13 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/messages/push/{messageId}".to_string().replace("{messageId}", &message_id.into().to_string()); + let path = "/messaging/messages/push/{messageId}" + .to_string() + .replace("{messageId}", &message_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new SMS message. @@ -361,13 +434,22 @@ impl Messaging { params.insert("messageId".to_string(), json!(message_id.into())); params.insert("content".to_string(), json!(content.into())); if let Some(value) = topics { - params.insert("topics".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "topics".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = users { - params.insert("users".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "users".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = targets { - params.insert("targets".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "targets".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = draft { params.insert("draft".to_string(), json!(value)); @@ -381,7 +463,9 @@ impl Messaging { let path = "/messaging/messages/sms".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an SMS message by its unique ID. This endpoint only works on @@ -400,13 +484,22 @@ impl Messaging { ) -> crate::error::Result { let mut params = HashMap::new(); if let Some(value) = topics { - params.insert("topics".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "topics".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = users { - params.insert("users".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "users".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = targets { - params.insert("targets".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "targets".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = content { params.insert("content".to_string(), json!(value)); @@ -421,9 +514,13 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/messages/sms/{messageId}".to_string().replace("{messageId}", &message_id.into().to_string()); + let path = "/messaging/messages/sms/{messageId}" + .to_string() + .replace("{messageId}", &message_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a message by its unique ID. @@ -435,24 +532,29 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/messages/{messageId}".to_string().replace("{messageId}", &message_id.into().to_string()); + let path = "/messaging/messages/{messageId}" + .to_string() + .replace("{messageId}", &message_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a message. If the message is not a draft or scheduled, but has been /// sent, this will not recall the message. - pub async fn delete( - &self, - message_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, message_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/messaging/messages/{messageId}".to_string().replace("{messageId}", &message_id.into().to_string()); + let path = "/messaging/messages/{messageId}" + .to_string() + .replace("{messageId}", &message_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of the targets associated with a message. @@ -464,7 +566,10 @@ impl Messaging { ) -> 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::>())); + 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)); @@ -472,9 +577,13 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/messages/{messageId}/targets".to_string().replace("{messageId}", &message_id.into().to_string()); + let path = "/messaging/messages/{messageId}/targets" + .to_string() + .replace("{messageId}", &message_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all providers from the current Appwrite project. @@ -486,7 +595,10 @@ impl Messaging { ) -> 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::>())); + 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)); @@ -499,7 +611,9 @@ impl Messaging { let path = "/messaging/providers".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Apple Push Notification service provider. @@ -542,7 +656,9 @@ impl Messaging { let path = "/messaging/providers/apns".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Apple Push Notification service provider by its unique ID. @@ -584,9 +700,13 @@ impl Messaging { 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/apns/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/apns/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Firebase Cloud Messaging provider. @@ -612,7 +732,9 @@ impl Messaging { let path = "/messaging/providers/fcm".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Firebase Cloud Messaging provider by its unique ID. @@ -637,9 +759,13 @@ impl Messaging { 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/fcm/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/fcm/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Mailgun provider. @@ -690,7 +816,9 @@ impl Messaging { let path = "/messaging/providers/mailgun".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Mailgun provider by its unique ID. @@ -740,9 +868,13 @@ impl Messaging { 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/mailgun/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/mailgun/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new MSG91 provider. @@ -776,7 +908,9 @@ impl Messaging { let path = "/messaging/providers/msg91".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a MSG91 provider by its unique ID. @@ -809,9 +943,13 @@ impl Messaging { 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/msg91/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/msg91/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Resend provider. @@ -854,7 +992,9 @@ impl Messaging { let path = "/messaging/providers/resend".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Resend provider by its unique ID. @@ -896,9 +1036,13 @@ impl Messaging { 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/resend/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/resend/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Sendgrid provider. @@ -941,7 +1085,9 @@ impl Messaging { let path = "/messaging/providers/sendgrid".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Sendgrid provider by its unique ID. @@ -983,9 +1129,13 @@ impl Messaging { 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/sendgrid/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/sendgrid/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Amazon SES provider. @@ -1036,7 +1186,9 @@ impl Messaging { let path = "/messaging/providers/ses".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an Amazon SES provider by its unique ID. @@ -1086,9 +1238,13 @@ impl Messaging { 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/ses/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/ses/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new SMTP provider. @@ -1153,7 +1309,9 @@ impl Messaging { let path = "/messaging/providers/smtp".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a SMTP provider by its unique ID. @@ -1219,9 +1377,13 @@ impl Messaging { 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/smtp/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/smtp/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Telesign provider. @@ -1255,7 +1417,9 @@ impl Messaging { let path = "/messaging/providers/telesign".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Telesign provider by its unique ID. @@ -1288,9 +1452,13 @@ impl Messaging { 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/telesign/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/telesign/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Textmagic provider. @@ -1324,7 +1492,9 @@ impl Messaging { let path = "/messaging/providers/textmagic".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Textmagic provider by its unique ID. @@ -1357,9 +1527,13 @@ impl Messaging { 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/textmagic/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/textmagic/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Twilio provider. @@ -1393,7 +1567,9 @@ impl Messaging { let path = "/messaging/providers/twilio".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Twilio provider by its unique ID. @@ -1426,9 +1602,13 @@ impl Messaging { 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/twilio/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/twilio/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a new Vonage provider. @@ -1462,7 +1642,9 @@ impl Messaging { let path = "/messaging/providers/vonage".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Vonage provider by its unique ID. @@ -1495,9 +1677,13 @@ impl Messaging { 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/vonage/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/vonage/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a provider by its unique ID. @@ -1509,9 +1695,13 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/providers/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a provider by its unique ID. @@ -1523,9 +1713,13 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/messaging/providers/{providerId}".to_string().replace("{providerId}", &provider_id.into().to_string()); + let path = "/messaging/providers/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all topics from the current Appwrite project. @@ -1537,7 +1731,10 @@ impl Messaging { ) -> 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::>())); + 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)); @@ -1550,7 +1747,9 @@ impl Messaging { let path = "/messaging/topics".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new topic. @@ -1564,7 +1763,10 @@ impl Messaging { params.insert("topicId".to_string(), json!(topic_id.into())); params.insert("name".to_string(), json!(name.into())); if let Some(value) = subscribe { - params.insert("subscribe".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "subscribe".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()); @@ -1572,7 +1774,9 @@ impl Messaging { let path = "/messaging/topics".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a topic by its unique ID. @@ -1584,9 +1788,13 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/topics/{topicId}".to_string().replace("{topicId}", &topic_id.into().to_string()); + let path = "/messaging/topics/{topicId}" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a topic by its unique ID. @@ -1601,29 +1809,37 @@ impl Messaging { params.insert("name".to_string(), json!(value)); } if let Some(value) = subscribe { - params.insert("subscribe".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "subscribe".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 = "/messaging/topics/{topicId}".to_string().replace("{topicId}", &topic_id.into().to_string()); + let path = "/messaging/topics/{topicId}" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a topic by its unique ID. - pub async fn delete_topic( - &self, - topic_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_topic(&self, topic_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/messaging/topics/{topicId}".to_string().replace("{topicId}", &topic_id.into().to_string()); + let path = "/messaging/topics/{topicId}" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all subscribers from the current Appwrite project. @@ -1636,7 +1852,10 @@ impl Messaging { ) -> 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::>())); + 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)); @@ -1647,9 +1866,13 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/topics/{topicId}/subscribers".to_string().replace("{topicId}", &topic_id.into().to_string()); + let path = "/messaging/topics/{topicId}/subscribers" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new subscriber. @@ -1666,9 +1889,13 @@ impl Messaging { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/topics/{topicId}/subscribers".to_string().replace("{topicId}", &topic_id.into().to_string()); + let path = "/messaging/topics/{topicId}/subscribers" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a subscriber by its unique ID. @@ -1681,9 +1908,14 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}".to_string().replace("{topicId}", &topic_id.into().to_string()).replace("{subscriberId}", &subscriber_id.into().to_string()); + let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()) + .replace("{subscriberId}", &subscriber_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a subscriber by its unique ID. @@ -1696,11 +1928,15 @@ impl Messaging { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}".to_string().replace("{topicId}", &topic_id.into().to_string()).replace("{subscriberId}", &subscriber_id.into().to_string()); + let path = "/messaging/topics/{topicId}/subscribers/{subscriberId}" + .to_string() + .replace("{topicId}", &topic_id.into().to_string()) + .replace("{subscriberId}", &subscriber_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Messaging { diff --git a/src/services/mod.rs b/src/services/mod.rs index 4ead3d3..3776795 100644 --- a/src/services/mod.rs +++ b/src/services/mod.rs @@ -12,6 +12,8 @@ pub mod backups; pub use backups::Backups; pub mod databases; pub use databases::Databases; +pub mod documents_db; +pub use documents_db::DocumentsDB; pub mod embeddings; pub use embeddings::Embeddings; pub mod functions; @@ -22,10 +24,16 @@ pub mod locale; pub use locale::Locale; pub mod messaging; pub use messaging::Messaging; +pub mod mongo; +pub use mongo::Mongo; +pub mod mysql; +pub use mysql::Mysql; pub mod oauth2; pub use oauth2::Oauth2; pub mod organization; pub use organization::Organization; +pub mod postgresql; +pub use postgresql::Postgresql; pub mod presences; pub use presences::Presences; pub mod project; @@ -46,6 +54,8 @@ pub mod tokens; pub use tokens::Tokens; pub mod users; pub use users::Users; +pub mod vectors_db; +pub use vectors_db::VectorsDB; pub mod webhooks; pub use webhooks::Webhooks; @@ -66,13 +76,17 @@ pub struct Services { avatars: Avatars, backups: Backups, databases: Databases, + documents_db: DocumentsDB, embeddings: Embeddings, functions: Functions, graphql: Graphql, locale: Locale, messaging: Messaging, + mongo: Mongo, + mysql: Mysql, oauth2: Oauth2, organization: Organization, + postgresql: Postgresql, presences: Presences, project: Project, proxy: Proxy, @@ -83,6 +97,7 @@ pub struct Services { teams: Teams, tokens: Tokens, users: Users, + vectors_db: VectorsDB, webhooks: Webhooks, } @@ -96,13 +111,17 @@ impl Services { avatars: Avatars::new(&client), backups: Backups::new(&client), databases: Databases::new(&client), + documents_db: DocumentsDB::new(&client), embeddings: Embeddings::new(&client), functions: Functions::new(&client), graphql: Graphql::new(&client), locale: Locale::new(&client), messaging: Messaging::new(&client), + mongo: Mongo::new(&client), + mysql: Mysql::new(&client), oauth2: Oauth2::new(&client), organization: Organization::new(&client), + postgresql: Postgresql::new(&client), presences: Presences::new(&client), project: Project::new(&client), proxy: Proxy::new(&client), @@ -113,6 +132,7 @@ impl Services { teams: Teams::new(&client), tokens: Tokens::new(&client), users: Users::new(&client), + vectors_db: VectorsDB::new(&client), webhooks: Webhooks::new(&client), client, } @@ -147,6 +167,10 @@ impl Services { pub fn databases(&self) -> &Databases { &self.databases } + /// Get DocumentsDB service + pub fn documents_db(&self) -> &DocumentsDB { + &self.documents_db + } /// Get Embeddings service pub fn embeddings(&self) -> &Embeddings { &self.embeddings @@ -167,6 +191,14 @@ impl Services { pub fn messaging(&self) -> &Messaging { &self.messaging } + /// Get Mongo service + pub fn mongo(&self) -> &Mongo { + &self.mongo + } + /// Get Mysql service + pub fn mysql(&self) -> &Mysql { + &self.mysql + } /// Get Oauth2 service pub fn oauth2(&self) -> &Oauth2 { &self.oauth2 @@ -175,6 +207,10 @@ impl Services { pub fn organization(&self) -> &Organization { &self.organization } + /// Get Postgresql service + pub fn postgresql(&self) -> &Postgresql { + &self.postgresql + } /// Get Presences service pub fn presences(&self) -> &Presences { &self.presences @@ -215,6 +251,10 @@ impl Services { pub fn users(&self) -> &Users { &self.users } + /// Get VectorsDB service + pub fn vectors_db(&self) -> &VectorsDB { + &self.vectors_db + } /// Get Webhooks service pub fn webhooks(&self) -> &Webhooks { &self.webhooks diff --git a/src/services/mongo.rs b/src/services/mongo.rs new file mode 100644 index 0000000..db5cc4e --- /dev/null +++ b/src/services/mongo.rs @@ -0,0 +1,971 @@ +//! Mongo service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct Mongo { + client: Client, +} + +impl Mongo { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// List all dedicated databases. Results support pagination. + pub async fn list( + &self, + 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 path = "/mongo".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new dedicated database with the chosen engine and configuration. + /// Status will be 'provisioning' until the database is ready. + #[allow(clippy::too_many_arguments)] + pub async fn create( + &self, + database_id: impl Into, + name: impl Into, + version: Option<&str>, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + network_idle_timeout_seconds: Option, + network_ip_allowlist: Option>, + idle_timeout_minutes: Option, + pitr: Option, + pitr_retention_days: Option, + storage_autoscaling: Option, + storage_autoscaling_threshold_percent: Option, + storage_autoscaling_max_gb: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("databaseId".to_string(), json!(database_id.into())); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = version { + params.insert("version".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".to_string(), json!(value)); + } + if let Some(value) = network_idle_timeout_seconds { + params.insert("networkIdleTimeoutSeconds".to_string(), json!(value)); + } + if let Some(value) = network_ip_allowlist { + params.insert( + "networkIPAllowlist".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = idle_timeout_minutes { + params.insert("idleTimeoutMinutes".to_string(), json!(value)); + } + if let Some(value) = pitr { + params.insert("pitr".to_string(), json!(value)); + } + if let Some(value) = pitr_retention_days { + params.insert("pitrRetentionDays".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling { + params.insert("storageAutoscaling".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling_threshold_percent { + params.insert( + "storageAutoscalingThresholdPercent".to_string(), + json!(value), + ); + } + if let Some(value) = storage_autoscaling_max_gb { + params.insert("storageAutoscalingMaxGb".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 = "/mongo".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the dedicated database specifications available on the current plan. + /// Each specification reports its resource limits, pricing, and whether it is + /// enabled for the organization. + pub async fn list_specifications( + &self, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/specifications".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a dedicated database by its unique ID. Returns the database + /// configuration and current status. + pub async fn get( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a dedicated database configuration. All changes are applied with + /// zero downtime. Specification changes (cpu, memory, storage) are handled via + /// rolling cutover. Storage expansion is done online. All other settings are + /// applied in-place. + #[allow(clippy::too_many_arguments)] + pub async fn update( + &self, + database_id: impl Into, + name: Option<&str>, + status: Option<&str>, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + network_idle_timeout_seconds: Option, + network_ip_allowlist: Option>, + idle_timeout_minutes: Option, + pitr: Option, + pitr_retention_days: Option, + storage_autoscaling: Option, + storage_autoscaling_threshold_percent: Option, + storage_autoscaling_max_gb: Option, + metrics_trace_sample_rate: Option, + metrics_slow_query_log_threshold_ms: Option, + sql_api_enabled: Option, + sql_api_allowed_statements: Option>, + sql_api_max_rows: Option, + sql_api_max_bytes: Option, + sql_api_timeout_seconds: 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) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".to_string(), json!(value)); + } + if let Some(value) = network_idle_timeout_seconds { + params.insert("networkIdleTimeoutSeconds".to_string(), json!(value)); + } + if let Some(value) = network_ip_allowlist { + params.insert( + "networkIPAllowlist".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = idle_timeout_minutes { + params.insert("idleTimeoutMinutes".to_string(), json!(value)); + } + if let Some(value) = pitr { + params.insert("pitr".to_string(), json!(value)); + } + if let Some(value) = pitr_retention_days { + params.insert("pitrRetentionDays".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling { + params.insert("storageAutoscaling".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling_threshold_percent { + params.insert( + "storageAutoscalingThresholdPercent".to_string(), + json!(value), + ); + } + if let Some(value) = storage_autoscaling_max_gb { + params.insert("storageAutoscalingMaxGb".to_string(), json!(value)); + } + if let Some(value) = metrics_trace_sample_rate { + params.insert("metricsTraceSampleRate".to_string(), json!(value)); + } + if let Some(value) = metrics_slow_query_log_threshold_ms { + params.insert("metricsSlowQueryLogThresholdMs".to_string(), json!(value)); + } + if let Some(value) = sql_api_enabled { + params.insert("sqlApiEnabled".to_string(), json!(value)); + } + if let Some(value) = sql_api_allowed_statements { + params.insert( + "sqlApiAllowedStatements".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = sql_api_max_rows { + params.insert("sqlApiMaxRows".to_string(), json!(value)); + } + if let Some(value) = sql_api_max_bytes { + params.insert("sqlApiMaxBytes".to_string(), json!(value)); + } + if let Some(value) = sql_api_timeout_seconds { + params.insert("sqlApiTimeoutSeconds".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 = "/mongo/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a dedicated database. This action is irreversible. The database + /// status will be set to 'deleting' and all resources will be cleaned up. + /// Deletion is allowed from any state, and repeating the call re-dispatches + /// the cleanup. + pub async fn delete( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List all backups for a dedicated database. Results can be filtered by + /// status and type. + pub async fn list_backups( + &self, + database_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 path = "/mongo/{databaseId}/backups" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a manual backup of a dedicated database. The backup will be created + /// asynchronously and its status can be checked via the get backup endpoint. + pub async fn create_backup( + &self, + database_id: impl Into, + r#type: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = r#type { + params.insert("type".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 = "/mongo/{databaseId}/backups" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List scheduled backup policies for a dedicated database. + pub async fn list_backup_policies( + &self, + database_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 path = "/mongo/{databaseId}/backups/policies" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a scheduled backup policy for a dedicated database. + #[allow(clippy::too_many_arguments)] + pub async fn create_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + name: impl Into, + schedule: impl Into, + retention: i64, + r#type: Option<&str>, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("policyId".to_string(), json!(policy_id.into())); + params.insert("name".to_string(), json!(name.into())); + params.insert("schedule".to_string(), json!(schedule.into())); + params.insert("retention".to_string(), json!(retention)); + if let Some(value) = r#type { + params.insert("type".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 = "/mongo/{databaseId}/backups/policies" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a scheduled backup policy for a dedicated database. + pub async fn get_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a scheduled backup policy for a dedicated database. + pub async fn update_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + name: Option<&str>, + schedule: Option<&str>, + retention: Option, + enabled: 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) = schedule { + params.insert("schedule".to_string(), json!(value)); + } + if let Some(value) = retention { + params.insert("retention".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 = "/mongo/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a scheduled backup policy for a dedicated database. Backups already + /// taken by the policy are kept until their retention expires. + pub async fn delete_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Configure off-cluster backup storage for a dedicated database. Supports S3, + /// GCS, and Azure Blob Storage destinations. Backups will be stored to the + /// configured destination in addition to on-cluster storage. + #[allow(clippy::too_many_arguments)] + pub async fn update_backup_storage( + &self, + database_id: impl Into, + provider: impl Into, + bucket: impl Into, + access_key: impl Into, + secret_key: impl Into, + region: Option<&str>, + prefix: Option<&str>, + endpoint: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("provider".to_string(), json!(provider.into())); + params.insert("bucket".to_string(), json!(bucket.into())); + if let Some(value) = region { + params.insert("region".to_string(), json!(value)); + } + if let Some(value) = prefix { + params.insert("prefix".to_string(), json!(value)); + } + if let Some(value) = endpoint { + params.insert("endpoint".to_string(), json!(value)); + } + params.insert("accessKey".to_string(), json!(access_key.into())); + params.insert("secretKey".to_string(), json!(secret_key.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 = "/mongo/{databaseId}/backups/storage" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Get details of a specific database backup including its status, size, and + /// timestamps. + pub async fn get_backup( + &self, + database_id: impl Into, + backup_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/backups/{backupId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{backupId}", &backup_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a database backup. This will permanently remove the backup from + /// storage and cannot be undone. + pub async fn delete_backup( + &self, + database_id: impl Into, + backup_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/backups/{backupId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{backupId}", &backup_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List all ephemeral branches for a dedicated database. Returns branch + /// metadata including ID, name, namespace, and expiration time. + pub async fn list_branches( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/branches" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create an ephemeral database branch from the primary via PVC snapshot. The + /// branch is a full copy of the database at the current point in time, useful + /// for testing schema migrations or running experiments without affecting + /// production data. Branches expire after the configured TTL (default 24 + /// hours). The branch is created asynchronously. + pub async fn create_branch( + &self, + database_id: impl Into, + branch_id: Option<&str>, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = branch_id { + params.insert("branchId".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 = "/mongo/{databaseId}/branches" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete an ephemeral database branch. This removes the branch namespace, its + /// PVC, and the associated VolumeSnapshot. The deletion runs asynchronously + /// and is irreversible. + pub async fn delete_branch( + &self, + database_id: impl Into, + branch_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/branches/{branchId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{branchId}", &branch_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Rotate the primary connection credentials for a dedicated database. + /// Generates a new password and updates the database atomically. Previous + /// credentials stop working immediately. Returns the database with a refreshed + /// connection string carrying the new password. + pub async fn update_credentials( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/credentials" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Trigger a manual failover for a dedicated database with high availability + /// enabled. Promotes a replica to primary. The failover runs asynchronously; + /// poll the database document for status updates. A database left + /// mid-operation also accepts this call as a repair once nothing is driving + /// the operation it is stuck in. Repairing a failover that did not finish, a + /// `failed` database, a stranded upgrade or migrate, or a stranded compute + /// resize additionally requires `targetReplicaId` to name the member to + /// promote, because the default target may be the member that operation + /// already promoted. + pub async fn create_failover( + &self, + database_id: impl Into, + target_replica_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = target_replica_id { + params.insert("targetReplicaId".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 = "/mongo/{databaseId}/failovers" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the maintenance window for a dedicated database. Maintenance + /// operations like minor version upgrades will be performed during this + /// window. + pub async fn update_maintenance( + &self, + database_id: impl Into, + day: impl Into, + hour_utc: i64, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("day".to_string(), json!(day.into())); + params.insert("hourUtc".to_string(), json!(hour_utc)); + let mut api_headers = 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 = "/mongo/{databaseId}/maintenance" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Migrate a database between shared and dedicated types. Shared to dedicated + /// provisions an always-on dedicated instance; dedicated to shared converts to + /// a serverless instance that scales to zero when idle. Data is copied to the + /// target with a brief read-only window during cutover. + pub async fn create_migration( + &self, + database_id: impl Into, + target_type: impl Into, + specification: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("targetType".to_string(), json!(target_type.into())); + if let Some(value) = specification { + params.insert("specification".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 = "/mongo/{databaseId}/migrations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the lifecycle operations recorded for a dedicated database, newest + /// first. Every provision, update, restore, backup and replication action is + /// recorded here with its outcome, including an attempt that was abandoned + /// because another worker took over the database. + pub async fn list_operations( + &self, + database_id: impl Into, + status: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/operations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get available point-in-time recovery windows for a dedicated database. + /// Returns the earliest and latest recovery points. + pub async fn get_pitr( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/pitr" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get high availability status for a dedicated database. Returns replica + /// statuses, replication lag, and sync mode. + pub async fn get_replicas( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/replicas" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// List all restorations for a dedicated database. Results can be filtered by + /// status and type. + pub async fn list_restorations( + &self, + database_id: impl Into, + status: Option<&str>, + r#type: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = r#type { + params.insert("type".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/restorations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Restore a database from a backup or to a specific point in time (PITR). For + /// backup restoration, provide a backupId. For PITR, provide a targetTime as + /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and + /// is only available for enterprise databases. + pub async fn create_restoration( + &self, + database_id: impl Into, + r#type: Option<&str>, + backup_id: Option<&str>, + target_database_id: Option<&str>, + target_time: Option<&str>, + ) -> 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) = backup_id { + params.insert("backupId".to_string(), json!(value)); + } + if let Some(value) = target_database_id { + params.insert("targetDatabaseId".to_string(), json!(value)); + } + if let Some(value) = target_time { + params.insert("targetTime".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 = "/mongo/{databaseId}/restorations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get details of a specific database restoration including its status, type, + /// and timestamps. + pub async fn get_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/restorations/{restorationId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{restorationId}", &restoration_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get real-time health and status information for a dedicated database. + /// Returns health status, readiness, uptime, connection info, replica status, + /// and volume information. + pub async fn get_status( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mongo/{databaseId}/status" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Upgrade a dedicated database to a new engine version. Uses blue-green + /// deployment for zero-downtime cutover. + pub async fn create_upgrade( + &self, + database_id: impl Into, + target_version: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("targetVersion".to_string(), json!(target_version.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 = "/mongo/{databaseId}/upgrades" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for Mongo { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_mongo_creation() { + let client = Client::new(); + let service = Mongo::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} diff --git a/src/services/mysql.rs b/src/services/mysql.rs new file mode 100644 index 0000000..4df7459 --- /dev/null +++ b/src/services/mysql.rs @@ -0,0 +1,1080 @@ +//! Mysql service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct Mysql { + client: Client, +} + +impl Mysql { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// List all dedicated databases. Results support pagination. + pub async fn list( + &self, + 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 path = "/mysql".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new dedicated database with the chosen engine and configuration. + /// Status will be 'provisioning' until the database is ready. + #[allow(clippy::too_many_arguments)] + pub async fn create( + &self, + database_id: impl Into, + name: impl Into, + version: Option<&str>, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + network_idle_timeout_seconds: Option, + network_ip_allowlist: Option>, + idle_timeout_minutes: Option, + pitr: Option, + pitr_retention_days: Option, + storage_autoscaling: Option, + storage_autoscaling_threshold_percent: Option, + storage_autoscaling_max_gb: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("databaseId".to_string(), json!(database_id.into())); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = version { + params.insert("version".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".to_string(), json!(value)); + } + if let Some(value) = network_idle_timeout_seconds { + params.insert("networkIdleTimeoutSeconds".to_string(), json!(value)); + } + if let Some(value) = network_ip_allowlist { + params.insert( + "networkIPAllowlist".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = idle_timeout_minutes { + params.insert("idleTimeoutMinutes".to_string(), json!(value)); + } + if let Some(value) = pitr { + params.insert("pitr".to_string(), json!(value)); + } + if let Some(value) = pitr_retention_days { + params.insert("pitrRetentionDays".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling { + params.insert("storageAutoscaling".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling_threshold_percent { + params.insert( + "storageAutoscalingThresholdPercent".to_string(), + json!(value), + ); + } + if let Some(value) = storage_autoscaling_max_gb { + params.insert("storageAutoscalingMaxGb".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 = "/mysql".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the dedicated database specifications available on the current plan. + /// Each specification reports its resource limits, pricing, and whether it is + /// enabled for the organization. + pub async fn list_specifications( + &self, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/specifications".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a dedicated database by its unique ID. Returns the database + /// configuration and current status. + pub async fn get( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a dedicated database configuration. All changes are applied with + /// zero downtime. Specification changes (cpu, memory, storage) are handled via + /// rolling cutover. Storage expansion is done online. All other settings are + /// applied in-place. + #[allow(clippy::too_many_arguments)] + pub async fn update( + &self, + database_id: impl Into, + name: Option<&str>, + status: Option<&str>, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + network_idle_timeout_seconds: Option, + network_ip_allowlist: Option>, + idle_timeout_minutes: Option, + pitr: Option, + pitr_retention_days: Option, + storage_autoscaling: Option, + storage_autoscaling_threshold_percent: Option, + storage_autoscaling_max_gb: Option, + metrics_trace_sample_rate: Option, + metrics_slow_query_log_threshold_ms: Option, + sql_api_enabled: Option, + sql_api_allowed_statements: Option>, + sql_api_max_rows: Option, + sql_api_max_bytes: Option, + sql_api_timeout_seconds: 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) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".to_string(), json!(value)); + } + if let Some(value) = network_idle_timeout_seconds { + params.insert("networkIdleTimeoutSeconds".to_string(), json!(value)); + } + if let Some(value) = network_ip_allowlist { + params.insert( + "networkIPAllowlist".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = idle_timeout_minutes { + params.insert("idleTimeoutMinutes".to_string(), json!(value)); + } + if let Some(value) = pitr { + params.insert("pitr".to_string(), json!(value)); + } + if let Some(value) = pitr_retention_days { + params.insert("pitrRetentionDays".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling { + params.insert("storageAutoscaling".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling_threshold_percent { + params.insert( + "storageAutoscalingThresholdPercent".to_string(), + json!(value), + ); + } + if let Some(value) = storage_autoscaling_max_gb { + params.insert("storageAutoscalingMaxGb".to_string(), json!(value)); + } + if let Some(value) = metrics_trace_sample_rate { + params.insert("metricsTraceSampleRate".to_string(), json!(value)); + } + if let Some(value) = metrics_slow_query_log_threshold_ms { + params.insert("metricsSlowQueryLogThresholdMs".to_string(), json!(value)); + } + if let Some(value) = sql_api_enabled { + params.insert("sqlApiEnabled".to_string(), json!(value)); + } + if let Some(value) = sql_api_allowed_statements { + params.insert( + "sqlApiAllowedStatements".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = sql_api_max_rows { + params.insert("sqlApiMaxRows".to_string(), json!(value)); + } + if let Some(value) = sql_api_max_bytes { + params.insert("sqlApiMaxBytes".to_string(), json!(value)); + } + if let Some(value) = sql_api_timeout_seconds { + params.insert("sqlApiTimeoutSeconds".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 = "/mysql/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a dedicated database. This action is irreversible. The database + /// status will be set to 'deleting' and all resources will be cleaned up. + /// Deletion is allowed from any state, and repeating the call re-dispatches + /// the cleanup. + pub async fn delete( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List all backups for a dedicated database. Results can be filtered by + /// status and type. + pub async fn list_backups( + &self, + database_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 path = "/mysql/{databaseId}/backups" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a manual backup of a dedicated database. The backup will be created + /// asynchronously and its status can be checked via the get backup endpoint. + pub async fn create_backup( + &self, + database_id: impl Into, + r#type: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = r#type { + params.insert("type".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 = "/mysql/{databaseId}/backups" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List scheduled backup policies for a dedicated database. + pub async fn list_backup_policies( + &self, + database_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 path = "/mysql/{databaseId}/backups/policies" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a scheduled backup policy for a dedicated database. + #[allow(clippy::too_many_arguments)] + pub async fn create_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + name: impl Into, + schedule: impl Into, + retention: i64, + r#type: Option<&str>, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("policyId".to_string(), json!(policy_id.into())); + params.insert("name".to_string(), json!(name.into())); + params.insert("schedule".to_string(), json!(schedule.into())); + params.insert("retention".to_string(), json!(retention)); + if let Some(value) = r#type { + params.insert("type".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 = "/mysql/{databaseId}/backups/policies" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a scheduled backup policy for a dedicated database. + pub async fn get_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a scheduled backup policy for a dedicated database. + pub async fn update_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + name: Option<&str>, + schedule: Option<&str>, + retention: Option, + enabled: 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) = schedule { + params.insert("schedule".to_string(), json!(value)); + } + if let Some(value) = retention { + params.insert("retention".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 = "/mysql/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a scheduled backup policy for a dedicated database. Backups already + /// taken by the policy are kept until their retention expires. + pub async fn delete_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Configure off-cluster backup storage for a dedicated database. Supports S3, + /// GCS, and Azure Blob Storage destinations. Backups will be stored to the + /// configured destination in addition to on-cluster storage. + #[allow(clippy::too_many_arguments)] + pub async fn update_backup_storage( + &self, + database_id: impl Into, + provider: impl Into, + bucket: impl Into, + access_key: impl Into, + secret_key: impl Into, + region: Option<&str>, + prefix: Option<&str>, + endpoint: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("provider".to_string(), json!(provider.into())); + params.insert("bucket".to_string(), json!(bucket.into())); + if let Some(value) = region { + params.insert("region".to_string(), json!(value)); + } + if let Some(value) = prefix { + params.insert("prefix".to_string(), json!(value)); + } + if let Some(value) = endpoint { + params.insert("endpoint".to_string(), json!(value)); + } + params.insert("accessKey".to_string(), json!(access_key.into())); + params.insert("secretKey".to_string(), json!(secret_key.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 = "/mysql/{databaseId}/backups/storage" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Get details of a specific database backup including its status, size, and + /// timestamps. + pub async fn get_backup( + &self, + database_id: impl Into, + backup_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/backups/{backupId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{backupId}", &backup_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a database backup. This will permanently remove the backup from + /// storage and cannot be undone. + pub async fn delete_backup( + &self, + database_id: impl Into, + backup_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/backups/{backupId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{backupId}", &backup_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List all ephemeral branches for a dedicated database. Returns branch + /// metadata including ID, name, namespace, and expiration time. + pub async fn list_branches( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/branches" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create an ephemeral database branch from the primary via PVC snapshot. The + /// branch is a full copy of the database at the current point in time, useful + /// for testing schema migrations or running experiments without affecting + /// production data. Branches expire after the configured TTL (default 24 + /// hours). The branch is created asynchronously. + pub async fn create_branch( + &self, + database_id: impl Into, + branch_id: Option<&str>, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = branch_id { + params.insert("branchId".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 = "/mysql/{databaseId}/branches" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete an ephemeral database branch. This removes the branch namespace, its + /// PVC, and the associated VolumeSnapshot. The deletion runs asynchronously + /// and is irreversible. + pub async fn delete_branch( + &self, + database_id: impl Into, + branch_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/branches/{branchId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{branchId}", &branch_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Rotate the primary connection credentials for a dedicated database. + /// Generates a new password and updates the database atomically. Previous + /// credentials stop working immediately. Returns the database with a refreshed + /// connection string carrying the new password. + pub async fn update_credentials( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/credentials" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Execute SQL through the console-facing Cloud endpoint. Cloud proxies + /// through the edge platform to the per-database SQL API sidecar. Application + /// traffic should bypass cloud entirely and POST directly to the per-database + /// hostname: + /// `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with + /// an `X-Appwrite-Key` header — that path scales to the whole DB fleet + /// without a per-query cloud round-trip. The statement type must be on the + /// database's configured allow-list. Use bound parameters for any + /// user-supplied values — the API does not interpolate raw strings. + pub async fn create_execution( + &self, + database_id: impl Into, + sql: impl Into, + bindings: Option, + timeout_seconds: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("sql".to_string(), json!(sql.into())); + if let Some(value) = bindings { + params.insert("bindings".to_string(), json!(value)); + } + if let Some(value) = timeout_seconds { + params.insert("timeoutSeconds".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 = "/mysql/{databaseId}/executions" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Trigger a manual failover for a dedicated database with high availability + /// enabled. Promotes a replica to primary. The failover runs asynchronously; + /// poll the database document for status updates. A database left + /// mid-operation also accepts this call as a repair once nothing is driving + /// the operation it is stuck in. Repairing a failover that did not finish, a + /// `failed` database, a stranded upgrade or migrate, or a stranded compute + /// resize additionally requires `targetReplicaId` to name the member to + /// promote, because the default target may be the member that operation + /// already promoted. + pub async fn create_failover( + &self, + database_id: impl Into, + target_replica_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = target_replica_id { + params.insert("targetReplicaId".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 = "/mysql/{databaseId}/failovers" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the maintenance window for a dedicated database. Maintenance + /// operations like minor version upgrades will be performed during this + /// window. + pub async fn update_maintenance( + &self, + database_id: impl Into, + day: impl Into, + hour_utc: i64, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("day".to_string(), json!(day.into())); + params.insert("hourUtc".to_string(), json!(hour_utc)); + let mut api_headers = 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 = "/mysql/{databaseId}/maintenance" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Migrate a database between shared and dedicated types. Shared to dedicated + /// provisions an always-on dedicated instance; dedicated to shared converts to + /// a serverless instance that scales to zero when idle. Data is copied to the + /// target with a brief read-only window during cutover. + pub async fn create_migration( + &self, + database_id: impl Into, + target_type: impl Into, + specification: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("targetType".to_string(), json!(target_type.into())); + if let Some(value) = specification { + params.insert("specification".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 = "/mysql/{databaseId}/migrations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the lifecycle operations recorded for a dedicated database, newest + /// first. Every provision, update, restore, backup and replication action is + /// recorded here with its outcome, including an attempt that was abandoned + /// because another worker took over the database. + pub async fn list_operations( + &self, + database_id: impl Into, + status: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/operations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get available point-in-time recovery windows for a dedicated database. + /// Returns the earliest and latest recovery points. + pub async fn get_pitr( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/pitr" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get the connection pooler configuration for a dedicated database. Returns + /// pooler mode, max connections, and pool size settings. + pub async fn get_pooler( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/pooler" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the connection pooler configuration for a dedicated database. + /// Configure pool mode, max connections, and pool sizes. + #[allow(clippy::too_many_arguments)] + pub async fn update_pooler( + &self, + database_id: impl Into, + mode: Option<&str>, + max_connections: Option, + default_pool_size: Option, + read_write_splitting: Option, + pooler_cpu_request: Option<&str>, + pooler_cpu_limit: Option<&str>, + pooler_memory_request: Option<&str>, + pooler_memory_limit: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = mode { + params.insert("mode".to_string(), json!(value)); + } + if let Some(value) = max_connections { + params.insert("maxConnections".to_string(), json!(value)); + } + if let Some(value) = default_pool_size { + params.insert("defaultPoolSize".to_string(), json!(value)); + } + if let Some(value) = read_write_splitting { + params.insert("readWriteSplitting".to_string(), json!(value)); + } + if let Some(value) = pooler_cpu_request { + params.insert("poolerCpuRequest".to_string(), json!(value)); + } + if let Some(value) = pooler_cpu_limit { + params.insert("poolerCpuLimit".to_string(), json!(value)); + } + if let Some(value) = pooler_memory_request { + params.insert("poolerMemoryRequest".to_string(), json!(value)); + } + if let Some(value) = pooler_memory_limit { + params.insert("poolerMemoryLimit".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 = "/mysql/{databaseId}/pooler" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Get high availability status for a dedicated database. Returns replica + /// statuses, replication lag, and sync mode. + pub async fn get_replicas( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/replicas" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// List all restorations for a dedicated database. Results can be filtered by + /// status and type. + pub async fn list_restorations( + &self, + database_id: impl Into, + status: Option<&str>, + r#type: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = r#type { + params.insert("type".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/restorations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Restore a database from a backup or to a specific point in time (PITR). For + /// backup restoration, provide a backupId. For PITR, provide a targetTime as + /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and + /// is only available for enterprise databases. + pub async fn create_restoration( + &self, + database_id: impl Into, + r#type: Option<&str>, + backup_id: Option<&str>, + target_database_id: Option<&str>, + target_time: Option<&str>, + ) -> 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) = backup_id { + params.insert("backupId".to_string(), json!(value)); + } + if let Some(value) = target_database_id { + params.insert("targetDatabaseId".to_string(), json!(value)); + } + if let Some(value) = target_time { + params.insert("targetTime".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 = "/mysql/{databaseId}/restorations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get details of a specific database restoration including its status, type, + /// and timestamps. + pub async fn get_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/restorations/{restorationId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{restorationId}", &restoration_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get real-time health and status information for a dedicated database. + /// Returns health status, readiness, uptime, connection info, replica status, + /// and volume information. + pub async fn get_status( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/mysql/{databaseId}/status" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Upgrade a dedicated database to a new engine version. Uses blue-green + /// deployment for zero-downtime cutover. + pub async fn create_upgrade( + &self, + database_id: impl Into, + target_version: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("targetVersion".to_string(), json!(target_version.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 = "/mysql/{databaseId}/upgrades" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for Mysql { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_mysql_creation() { + let client = Client::new(); + let service = Mysql::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} diff --git a/src/services/oauth2.rs b/src/services/oauth2.rs index 3df72da..e46bfaf 100644 --- a/src/services/oauth2.rs +++ b/src/services/oauth2.rs @@ -15,7 +15,9 @@ pub struct Oauth2 { impl Oauth2 { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -45,9 +47,19 @@ impl Oauth2 { 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}/approve".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 + let path = "/oauth2/{project_id}/approve".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 } /// Begin the OAuth2 authorization flow. When called without a session, the @@ -119,9 +131,19 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/oauth2/{project_id}/authorize".to_string().replace("{project_id}", &self.client.get_headers().get("x-appwrite-project").cloned().unwrap_or_default()); - - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + let path = "/oauth2/{project_id}/authorize".to_string().replace( + "{project_id}", + &self + .client + .get_headers() + .get("x-appwrite-project") + .cloned() + .unwrap_or_default(), + ); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Begin the OAuth2 authorization flow. When called without a session, the @@ -194,9 +216,19 @@ impl Oauth2 { 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}/authorize".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 + let path = "/oauth2/{project_id}/authorize".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 } /// Start the OAuth2 Device Authorization Grant. Returns the device code, user @@ -229,9 +261,21 @@ impl Oauth2 { 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}/device_authorization".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 + let path = "/oauth2/{project_id}/device_authorization" + .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 } /// Exchange a device flow user code for an OAuth2 grant. The authenticated @@ -248,9 +292,19 @@ impl Oauth2 { 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}/grants".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 + let path = "/oauth2/{project_id}/grants".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 } /// Get an OAuth2 grant by its ID. Used by the consent screen to display the @@ -264,9 +318,22 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/oauth2/{project_id}/grants/{grant_id}".to_string().replace("{project_id}", &self.client.get_headers().get("x-appwrite-project").cloned().unwrap_or_default()).replace("{grant_id}", &grant_id.into().to_string()); - - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + let path = "/oauth2/{project_id}/grants/{grant_id}" + .to_string() + .replace( + "{project_id}", + &self + .client + .get_headers() + .get("x-appwrite-project") + .cloned() + .unwrap_or_default(), + ) + .replace("{grant_id}", &grant_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// List the organizations the OAuth2 access token can access. Resolves the @@ -291,9 +358,19 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/oauth2/{project_id}/organizations".to_string().replace("{project_id}", &self.client.get_headers().get("x-appwrite-project").cloned().unwrap_or_default()); - - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + let path = "/oauth2/{project_id}/organizations".to_string().replace( + "{project_id}", + &self + .client + .get_headers() + .get("x-appwrite-project") + .cloned() + .unwrap_or_default(), + ); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Store an OAuth2 authorization request server-side and receive a short-lived @@ -353,9 +430,19 @@ impl Oauth2 { 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}/par".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 + let path = "/oauth2/{project_id}/par".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 projects the OAuth2 access token can access. Resolves the token's @@ -380,9 +467,19 @@ impl Oauth2 { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/oauth2/{project_id}/projects".to_string().replace("{project_id}", &self.client.get_headers().get("x-appwrite-project").cloned().unwrap_or_default()); - - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + let path = "/oauth2/{project_id}/projects".to_string().replace( + "{project_id}", + &self + .client + .get_headers() + .get("x-appwrite-project") + .cloned() + .unwrap_or_default(), + ); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Reject an OAuth2 grant when the user denies consent. Returns the @@ -399,9 +496,19 @@ impl Oauth2 { 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}/reject".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 + let path = "/oauth2/{project_id}/reject".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 } /// Revoke an OAuth2 access token or refresh token. @@ -427,9 +534,19 @@ impl Oauth2 { 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}/revoke".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 + let path = "/oauth2/{project_id}/revoke".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 } /// Exchange an OAuth2 authorization code, refresh token, or device code for @@ -481,11 +598,20 @@ impl Oauth2 { 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}/token".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 + let path = "/oauth2/{project_id}/token".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 } - } impl crate::services::Service for Oauth2 { diff --git a/src/services/organization.rs b/src/services/organization.rs index 6911285..ccc9a26 100644 --- a/src/services/organization.rs +++ b/src/services/organization.rs @@ -14,7 +14,9 @@ pub struct Organization { impl Organization { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -22,16 +24,16 @@ impl Organization { } /// Get the current organization. - pub async fn get( - &self, - ) -> crate::error::Result { + pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/organization".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update the current organization's name. @@ -47,21 +49,23 @@ impl Organization { let path = "/organization".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete the current organization. All projects that belong to the /// organization are deleted as well. - pub async fn delete( - &self, - ) -> crate::error::Result<()> { + pub async fn delete(&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()); let path = "/organization".to_string(); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List app installations on the organization. Any organization member can @@ -73,7 +77,10 @@ impl Organization { ) -> 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::>())); + 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)); @@ -83,7 +90,9 @@ impl Organization { let path = "/organization/installations".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Install an app on the organization. Only organization members with the @@ -105,7 +114,9 @@ impl Organization { let path = "/organization/installations".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get an app installation on the organization by its unique ID. Any @@ -118,9 +129,13 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}".to_string().replace("{installationId}", &installation_id.into().to_string()); + let path = "/organization/installations/{installationId}" + .to_string() + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update an app installation on the organization. Only organization members @@ -140,9 +155,13 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}".to_string().replace("{installationId}", &installation_id.into().to_string()); + let path = "/organization/installations/{installationId}" + .to_string() + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Uninstall an app from the organization by its installation ID. Only @@ -157,9 +176,13 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/installations/{installationId}".to_string().replace("{installationId}", &installation_id.into().to_string()); + let path = "/organization/installations/{installationId}" + .to_string() + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all API keys from the current organization. @@ -170,7 +193,10 @@ impl Organization { ) -> 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::>())); + 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)); @@ -180,7 +206,9 @@ impl Organization { let path = "/organization/keys".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new organization API key. @@ -204,7 +232,9 @@ impl Organization { let path = "/organization/keys".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a key by its unique ID. This endpoint returns details about a specific @@ -217,9 +247,13 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}".to_string().replace("{keyId}", &key_id.into().to_string()); + let path = "/organization/keys/{keyId}" + .to_string() + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a key by its unique ID. Use this endpoint to update the name, @@ -241,24 +275,29 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}".to_string().replace("{keyId}", &key_id.into().to_string()); + let path = "/organization/keys/{keyId}" + .to_string() + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a key by its unique ID. Once deleted, the key can no longer be used /// to authenticate API calls. - pub async fn delete_key( - &self, - key_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_key(&self, key_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/organization/keys/{keyId}".to_string().replace("{keyId}", &key_id.into().to_string()); + let path = "/organization/keys/{keyId}" + .to_string() + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all memberships from the current organization. @@ -270,7 +309,10 @@ impl Organization { ) -> 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::>())); + 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)); @@ -283,7 +325,9 @@ impl Organization { let path = "/organization/memberships".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Invite a new member to join the current organization. An email with a link @@ -308,7 +352,10 @@ impl Organization { if let Some(value) = phone { params.insert("phone".to_string(), json!(value)); } - params.insert("roles".to_string(), json!(roles.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "roles".to_string(), + json!(roles.into_iter().map(|s| s.into()).collect::>()), + ); if let Some(value) = url { params.insert("url".to_string(), json!(value)); } @@ -321,7 +368,9 @@ impl Organization { let path = "/organization/memberships".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a membership from the current organization by its unique ID. @@ -333,9 +382,13 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/memberships/{membershipId}".to_string().replace("{membershipId}", &membership_id.into().to_string()); + let path = "/organization/memberships/{membershipId}" + .to_string() + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Modify the roles of a member in the current organization. @@ -345,14 +398,21 @@ impl Organization { roles: impl IntoIterator>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("roles".to_string(), json!(roles.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "roles".to_string(), + json!(roles.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 = "/organization/memberships/{membershipId}".to_string().replace("{membershipId}", &membership_id.into().to_string()); + let path = "/organization/memberships/{membershipId}" + .to_string() + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Remove a member from the current organization. The member is removed @@ -366,9 +426,13 @@ impl Organization { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/organization/memberships/{membershipId}".to_string().replace("{membershipId}", &membership_id.into().to_string()); + let path = "/organization/memberships/{membershipId}" + .to_string() + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all projects. You can use the query params to filter your @@ -381,7 +445,10 @@ impl Organization { ) -> 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::>())); + 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)); @@ -394,7 +461,9 @@ impl Organization { let path = "/organization/projects".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new project. @@ -416,7 +485,9 @@ impl Organization { let path = "/organization/projects".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a project. @@ -426,9 +497,13 @@ impl Organization { ) -> crate::error::Result { let params = HashMap::new(); - let path = "/organization/projects/{projectId}".to_string().replace("{projectId}", &project_id.into().to_string()); + let path = "/organization/projects/{projectId}" + .to_string() + .replace("{projectId}", &project_id.into().to_string()); - self.client.call(Method::GET, &path, None, Some(params)).await + self.client + .call(Method::GET, &path, None, Some(params)) + .await } /// Update a project by its unique ID. @@ -443,25 +518,29 @@ impl Organization { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/organization/projects/{projectId}".to_string().replace("{projectId}", &project_id.into().to_string()); + let path = "/organization/projects/{projectId}" + .to_string() + .replace("{projectId}", &project_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a project by its unique ID. - pub async fn delete_project( - &self, - project_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_project(&self, project_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/organization/projects/{projectId}".to_string().replace("{projectId}", &project_id.into().to_string()); + let path = "/organization/projects/{projectId}" + .to_string() + .replace("{projectId}", &project_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Organization { diff --git a/src/services/postgresql.rs b/src/services/postgresql.rs new file mode 100644 index 0000000..fb720b9 --- /dev/null +++ b/src/services/postgresql.rs @@ -0,0 +1,1142 @@ +//! Postgresql service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct Postgresql { + client: Client, +} + +impl Postgresql { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// List all dedicated databases. Results support pagination. + pub async fn list( + &self, + 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 path = "/postgresql".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new dedicated database with the chosen engine and configuration. + /// Status will be 'provisioning' until the database is ready. + #[allow(clippy::too_many_arguments)] + pub async fn create( + &self, + database_id: impl Into, + name: impl Into, + version: Option<&str>, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + network_idle_timeout_seconds: Option, + network_ip_allowlist: Option>, + idle_timeout_minutes: Option, + pitr: Option, + pitr_retention_days: Option, + storage_autoscaling: Option, + storage_autoscaling_threshold_percent: Option, + storage_autoscaling_max_gb: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("databaseId".to_string(), json!(database_id.into())); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = version { + params.insert("version".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".to_string(), json!(value)); + } + if let Some(value) = network_idle_timeout_seconds { + params.insert("networkIdleTimeoutSeconds".to_string(), json!(value)); + } + if let Some(value) = network_ip_allowlist { + params.insert( + "networkIPAllowlist".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = idle_timeout_minutes { + params.insert("idleTimeoutMinutes".to_string(), json!(value)); + } + if let Some(value) = pitr { + params.insert("pitr".to_string(), json!(value)); + } + if let Some(value) = pitr_retention_days { + params.insert("pitrRetentionDays".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling { + params.insert("storageAutoscaling".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling_threshold_percent { + params.insert( + "storageAutoscalingThresholdPercent".to_string(), + json!(value), + ); + } + if let Some(value) = storage_autoscaling_max_gb { + params.insert("storageAutoscalingMaxGb".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 = "/postgresql".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the dedicated database specifications available on the current plan. + /// Each specification reports its resource limits, pricing, and whether it is + /// enabled for the organization. + pub async fn list_specifications( + &self, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/specifications".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a dedicated database by its unique ID. Returns the database + /// configuration and current status. + pub async fn get( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a dedicated database configuration. All changes are applied with + /// zero downtime. Specification changes (cpu, memory, storage) are handled via + /// rolling cutover. Storage expansion is done online. All other settings are + /// applied in-place. + #[allow(clippy::too_many_arguments)] + pub async fn update( + &self, + database_id: impl Into, + name: Option<&str>, + status: Option<&str>, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + network_idle_timeout_seconds: Option, + network_ip_allowlist: Option>, + idle_timeout_minutes: Option, + pitr: Option, + pitr_retention_days: Option, + storage_autoscaling: Option, + storage_autoscaling_threshold_percent: Option, + storage_autoscaling_max_gb: Option, + metrics_trace_sample_rate: Option, + metrics_slow_query_log_threshold_ms: Option, + sql_api_enabled: Option, + sql_api_allowed_statements: Option>, + sql_api_max_rows: Option, + sql_api_max_bytes: Option, + sql_api_timeout_seconds: 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) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".to_string(), json!(value)); + } + if let Some(value) = network_idle_timeout_seconds { + params.insert("networkIdleTimeoutSeconds".to_string(), json!(value)); + } + if let Some(value) = network_ip_allowlist { + params.insert( + "networkIPAllowlist".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = idle_timeout_minutes { + params.insert("idleTimeoutMinutes".to_string(), json!(value)); + } + if let Some(value) = pitr { + params.insert("pitr".to_string(), json!(value)); + } + if let Some(value) = pitr_retention_days { + params.insert("pitrRetentionDays".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling { + params.insert("storageAutoscaling".to_string(), json!(value)); + } + if let Some(value) = storage_autoscaling_threshold_percent { + params.insert( + "storageAutoscalingThresholdPercent".to_string(), + json!(value), + ); + } + if let Some(value) = storage_autoscaling_max_gb { + params.insert("storageAutoscalingMaxGb".to_string(), json!(value)); + } + if let Some(value) = metrics_trace_sample_rate { + params.insert("metricsTraceSampleRate".to_string(), json!(value)); + } + if let Some(value) = metrics_slow_query_log_threshold_ms { + params.insert("metricsSlowQueryLogThresholdMs".to_string(), json!(value)); + } + if let Some(value) = sql_api_enabled { + params.insert("sqlApiEnabled".to_string(), json!(value)); + } + if let Some(value) = sql_api_allowed_statements { + params.insert( + "sqlApiAllowedStatements".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = sql_api_max_rows { + params.insert("sqlApiMaxRows".to_string(), json!(value)); + } + if let Some(value) = sql_api_max_bytes { + params.insert("sqlApiMaxBytes".to_string(), json!(value)); + } + if let Some(value) = sql_api_timeout_seconds { + params.insert("sqlApiTimeoutSeconds".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 = "/postgresql/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a dedicated database. This action is irreversible. The database + /// status will be set to 'deleting' and all resources will be cleaned up. + /// Deletion is allowed from any state, and repeating the call re-dispatches + /// the cleanup. + pub async fn delete( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List all backups for a dedicated database. Results can be filtered by + /// status and type. + pub async fn list_backups( + &self, + database_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 path = "/postgresql/{databaseId}/backups" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a manual backup of a dedicated database. The backup will be created + /// asynchronously and its status can be checked via the get backup endpoint. + pub async fn create_backup( + &self, + database_id: impl Into, + r#type: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = r#type { + params.insert("type".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 = "/postgresql/{databaseId}/backups" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List scheduled backup policies for a dedicated database. + pub async fn list_backup_policies( + &self, + database_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 path = "/postgresql/{databaseId}/backups/policies" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a scheduled backup policy for a dedicated database. + #[allow(clippy::too_many_arguments)] + pub async fn create_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + name: impl Into, + schedule: impl Into, + retention: i64, + r#type: Option<&str>, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("policyId".to_string(), json!(policy_id.into())); + params.insert("name".to_string(), json!(name.into())); + params.insert("schedule".to_string(), json!(schedule.into())); + params.insert("retention".to_string(), json!(retention)); + if let Some(value) = r#type { + params.insert("type".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 = "/postgresql/{databaseId}/backups/policies" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a scheduled backup policy for a dedicated database. + pub async fn get_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a scheduled backup policy for a dedicated database. + pub async fn update_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + name: Option<&str>, + schedule: Option<&str>, + retention: Option, + enabled: 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) = schedule { + params.insert("schedule".to_string(), json!(value)); + } + if let Some(value) = retention { + params.insert("retention".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 = "/postgresql/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a scheduled backup policy for a dedicated database. Backups already + /// taken by the policy are kept until their retention expires. + pub async fn delete_backup_policy( + &self, + database_id: impl Into, + policy_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/backups/policies/{policyId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{policyId}", &policy_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Configure off-cluster backup storage for a dedicated database. Supports S3, + /// GCS, and Azure Blob Storage destinations. Backups will be stored to the + /// configured destination in addition to on-cluster storage. + #[allow(clippy::too_many_arguments)] + pub async fn update_backup_storage( + &self, + database_id: impl Into, + provider: impl Into, + bucket: impl Into, + access_key: impl Into, + secret_key: impl Into, + region: Option<&str>, + prefix: Option<&str>, + endpoint: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("provider".to_string(), json!(provider.into())); + params.insert("bucket".to_string(), json!(bucket.into())); + if let Some(value) = region { + params.insert("region".to_string(), json!(value)); + } + if let Some(value) = prefix { + params.insert("prefix".to_string(), json!(value)); + } + if let Some(value) = endpoint { + params.insert("endpoint".to_string(), json!(value)); + } + params.insert("accessKey".to_string(), json!(access_key.into())); + params.insert("secretKey".to_string(), json!(secret_key.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 = "/postgresql/{databaseId}/backups/storage" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Get details of a specific database backup including its status, size, and + /// timestamps. + pub async fn get_backup( + &self, + database_id: impl Into, + backup_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/backups/{backupId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{backupId}", &backup_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a database backup. This will permanently remove the backup from + /// storage and cannot be undone. + pub async fn delete_backup( + &self, + database_id: impl Into, + backup_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/backups/{backupId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{backupId}", &backup_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List all ephemeral branches for a dedicated database. Returns branch + /// metadata including ID, name, namespace, and expiration time. + pub async fn list_branches( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/branches" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create an ephemeral database branch from the primary via PVC snapshot. The + /// branch is a full copy of the database at the current point in time, useful + /// for testing schema migrations or running experiments without affecting + /// production data. Branches expire after the configured TTL (default 24 + /// hours). The branch is created asynchronously. + pub async fn create_branch( + &self, + database_id: impl Into, + branch_id: Option<&str>, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = branch_id { + params.insert("branchId".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 = "/postgresql/{databaseId}/branches" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete an ephemeral database branch. This removes the branch namespace, its + /// PVC, and the associated VolumeSnapshot. The deletion runs asynchronously + /// and is irreversible. + pub async fn delete_branch( + &self, + database_id: impl Into, + branch_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/branches/{branchId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{branchId}", &branch_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Rotate the primary connection credentials for a dedicated database. + /// Generates a new password and updates the database atomically. Previous + /// credentials stop working immediately. Returns the database with a refreshed + /// connection string carrying the new password. + pub async fn update_credentials( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/credentials" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Execute SQL through the console-facing Cloud endpoint. Cloud proxies + /// through the edge platform to the per-database SQL API sidecar. Application + /// traffic should bypass cloud entirely and POST directly to the per-database + /// hostname: + /// `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with + /// an `X-Appwrite-Key` header — that path scales to the whole DB fleet + /// without a per-query cloud round-trip. The statement type must be on the + /// database's configured allow-list. Use bound parameters for any + /// user-supplied values — the API does not interpolate raw strings. + pub async fn create_execution( + &self, + database_id: impl Into, + sql: impl Into, + bindings: Option, + timeout_seconds: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("sql".to_string(), json!(sql.into())); + if let Some(value) = bindings { + params.insert("bindings".to_string(), json!(value)); + } + if let Some(value) = timeout_seconds { + params.insert("timeoutSeconds".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 = "/postgresql/{databaseId}/executions" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List installed and available extensions for a PostgreSQL database. + pub async fn list_extensions( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/extensions" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Install a database extension. Only available for PostgreSQL databases. The + /// install runs asynchronously; poll the extensions list endpoint for status. + pub async fn create_extension( + &self, + database_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 path = "/postgresql/{databaseId}/extensions" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Uninstall a database extension from a PostgreSQL database. The uninstall + /// runs asynchronously; poll the extensions list endpoint for status. + pub async fn delete_extension( + &self, + database_id: impl Into, + extension_name: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/extensions/{extensionName}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{extensionName}", &extension_name.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Trigger a manual failover for a dedicated database with high availability + /// enabled. Promotes a replica to primary. The failover runs asynchronously; + /// poll the database document for status updates. A database left + /// mid-operation also accepts this call as a repair once nothing is driving + /// the operation it is stuck in. Repairing a failover that did not finish, a + /// `failed` database, a stranded upgrade or migrate, or a stranded compute + /// resize additionally requires `targetReplicaId` to name the member to + /// promote, because the default target may be the member that operation + /// already promoted. + pub async fn create_failover( + &self, + database_id: impl Into, + target_replica_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = target_replica_id { + params.insert("targetReplicaId".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 = "/postgresql/{databaseId}/failovers" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the maintenance window for a dedicated database. Maintenance + /// operations like minor version upgrades will be performed during this + /// window. + pub async fn update_maintenance( + &self, + database_id: impl Into, + day: impl Into, + hour_utc: i64, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("day".to_string(), json!(day.into())); + params.insert("hourUtc".to_string(), json!(hour_utc)); + let mut api_headers = 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 = "/postgresql/{databaseId}/maintenance" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Migrate a database between shared and dedicated types. Shared to dedicated + /// provisions an always-on dedicated instance; dedicated to shared converts to + /// a serverless instance that scales to zero when idle. Data is copied to the + /// target with a brief read-only window during cutover. + pub async fn create_migration( + &self, + database_id: impl Into, + target_type: impl Into, + specification: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("targetType".to_string(), json!(target_type.into())); + if let Some(value) = specification { + params.insert("specification".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 = "/postgresql/{databaseId}/migrations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the lifecycle operations recorded for a dedicated database, newest + /// first. Every provision, update, restore, backup and replication action is + /// recorded here with its outcome, including an attempt that was abandoned + /// because another worker took over the database. + pub async fn list_operations( + &self, + database_id: impl Into, + status: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/operations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get available point-in-time recovery windows for a dedicated database. + /// Returns the earliest and latest recovery points. + pub async fn get_pitr( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/pitr" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get the connection pooler configuration for a dedicated database. Returns + /// pooler mode, max connections, and pool size settings. + pub async fn get_pooler( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/pooler" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the connection pooler configuration for a dedicated database. + /// Configure pool mode, max connections, and pool sizes. + #[allow(clippy::too_many_arguments)] + pub async fn update_pooler( + &self, + database_id: impl Into, + mode: Option<&str>, + max_connections: Option, + default_pool_size: Option, + read_write_splitting: Option, + pooler_cpu_request: Option<&str>, + pooler_cpu_limit: Option<&str>, + pooler_memory_request: Option<&str>, + pooler_memory_limit: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = mode { + params.insert("mode".to_string(), json!(value)); + } + if let Some(value) = max_connections { + params.insert("maxConnections".to_string(), json!(value)); + } + if let Some(value) = default_pool_size { + params.insert("defaultPoolSize".to_string(), json!(value)); + } + if let Some(value) = read_write_splitting { + params.insert("readWriteSplitting".to_string(), json!(value)); + } + if let Some(value) = pooler_cpu_request { + params.insert("poolerCpuRequest".to_string(), json!(value)); + } + if let Some(value) = pooler_cpu_limit { + params.insert("poolerCpuLimit".to_string(), json!(value)); + } + if let Some(value) = pooler_memory_request { + params.insert("poolerMemoryRequest".to_string(), json!(value)); + } + if let Some(value) = pooler_memory_limit { + params.insert("poolerMemoryLimit".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 = "/postgresql/{databaseId}/pooler" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Get high availability status for a dedicated database. Returns replica + /// statuses, replication lag, and sync mode. + pub async fn get_replicas( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/replicas" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// List all restorations for a dedicated database. Results can be filtered by + /// status and type. + pub async fn list_restorations( + &self, + database_id: impl Into, + status: Option<&str>, + r#type: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = r#type { + params.insert("type".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/restorations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Restore a database from a backup or to a specific point in time (PITR). For + /// backup restoration, provide a backupId. For PITR, provide a targetTime as + /// an ISO 8601 datetime. PITR requires the database to have PITR enabled and + /// is only available for enterprise databases. + pub async fn create_restoration( + &self, + database_id: impl Into, + r#type: Option<&str>, + backup_id: Option<&str>, + target_database_id: Option<&str>, + target_time: Option<&str>, + ) -> 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) = backup_id { + params.insert("backupId".to_string(), json!(value)); + } + if let Some(value) = target_database_id { + params.insert("targetDatabaseId".to_string(), json!(value)); + } + if let Some(value) = target_time { + params.insert("targetTime".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 = "/postgresql/{databaseId}/restorations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get details of a specific database restoration including its status, type, + /// and timestamps. + pub async fn get_restoration( + &self, + database_id: impl Into, + restoration_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/restorations/{restorationId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{restorationId}", &restoration_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get real-time health and status information for a dedicated database. + /// Returns health status, readiness, uptime, connection info, replica status, + /// and volume information. + pub async fn get_status( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/postgresql/{databaseId}/status" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Upgrade a dedicated database to a new engine version. Uses blue-green + /// deployment for zero-downtime cutover. + pub async fn create_upgrade( + &self, + database_id: impl Into, + target_version: impl Into, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("targetVersion".to_string(), json!(target_version.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 = "/postgresql/{databaseId}/upgrades" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for Postgresql { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_postgresql_creation() { + let client = Client::new(); + let service = Postgresql::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} diff --git a/src/services/presences.rs b/src/services/presences.rs index 081dc01..2954c14 100644 --- a/src/services/presences.rs +++ b/src/services/presences.rs @@ -15,7 +15,9 @@ pub struct Presences { impl Presences { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -31,7 +33,10 @@ impl Presences { ) -> 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::>())); + 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)); @@ -44,7 +49,9 @@ impl Presences { let path = "/presences".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the @@ -57,9 +64,13 @@ impl Presences { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/presences/{presenceId}".to_string().replace("{presenceId}", &presence_id.into().to_string()); + let path = "/presences/{presenceId}" + .to_string() + .replace("{presenceId}", &presence_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create or update a presence log by its user ID. @@ -76,7 +87,10 @@ impl Presences { params.insert("userId".to_string(), json!(user_id.into())); params.insert("status".to_string(), json!(status.into())); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = expires_at { params.insert("expiresAt".to_string(), json!(value)); @@ -88,9 +102,13 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/presences/{presenceId}".to_string().replace("{presenceId}", &presence_id.into().to_string()); + let path = "/presences/{presenceId}" + .to_string() + .replace("{presenceId}", &presence_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Update a presence log by its unique ID. Using the patch method you can pass @@ -118,7 +136,10 @@ impl Presences { params.insert("metadata".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = purge { params.insert("purge".to_string(), json!(value)); @@ -127,25 +148,29 @@ impl Presences { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/presences/{presenceId}".to_string().replace("{presenceId}", &presence_id.into().to_string()); + let path = "/presences/{presenceId}" + .to_string() + .replace("{presenceId}", &presence_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a presence log by its unique ID. - pub async fn delete( - &self, - presence_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, presence_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/presences/{presenceId}".to_string().replace("{presenceId}", &presence_id.into().to_string()); + let path = "/presences/{presenceId}" + .to_string() + .replace("{presenceId}", &presence_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Presences { diff --git a/src/services/project.rs b/src/services/project.rs index fa16dee..3665a29 100644 --- a/src/services/project.rs +++ b/src/services/project.rs @@ -15,7 +15,9 @@ pub struct Project { impl Project { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -23,27 +25,27 @@ impl Project { } /// Get a project. - pub async fn get( - &self, - ) -> crate::error::Result { + pub async fn get(&self) -> crate::error::Result { let params = HashMap::new(); let path = "/project".to_string(); - self.client.call(Method::GET, &path, None, Some(params)).await + self.client + .call(Method::GET, &path, None, Some(params)) + .await } /// Delete a project. - pub async fn delete( - &self, - ) -> crate::error::Result<()> { + pub async fn delete(&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()); let path = "/project".to_string(); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update properties of a specific auth method. Use this endpoint to enable or @@ -59,9 +61,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/auth-methods/{methodId}".to_string().replace("{methodId}", &method_id.to_string()); + let path = "/project/auth-methods/{methodId}" + .to_string() + .replace("{methodId}", &method_id.to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all API keys from the current project. @@ -72,7 +78,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -82,12 +91,14 @@ impl Project { let path = "/project/keys".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new ephemeral API key. 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_key( @@ -104,7 +115,9 @@ impl Project { let path = "/project/keys/ephemeral".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a key by its unique ID. @@ -116,9 +129,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/keys/{keyId}".to_string().replace("{keyId}", &key_id.into().to_string()); + let path = "/project/keys/{keyId}" + .to_string() + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a key by its unique ID. Use this endpoint to update the name, @@ -140,24 +157,29 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/keys/{keyId}".to_string().replace("{keyId}", &key_id.into().to_string()); + let path = "/project/keys/{keyId}" + .to_string() + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a key by its unique ID. Once deleted, the key can no longer be used /// to authenticate API calls. - pub async fn delete_key( - &self, - key_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_key(&self, key_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/project/keys/{keyId}".to_string().replace("{keyId}", &key_id.into().to_string()); + let path = "/project/keys/{keyId}" + .to_string() + .replace("{keyId}", &key_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the project labels. Labels can be used to easily filter projects in @@ -167,14 +189,22 @@ impl Project { labels: impl IntoIterator>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("labels".to_string(), json!(labels.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "labels".to_string(), + json!(labels + .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 = "/project/labels".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all mock phones in the project. This endpoint returns an @@ -186,7 +216,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -196,7 +229,9 @@ impl Project { let path = "/project/mock-phones".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new mock phone for your project. Use this endpoint to register a @@ -215,7 +250,9 @@ impl Project { let path = "/project/mock-phones".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a mock phone by its unique number. This endpoint returns the mock @@ -228,9 +265,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/mock-phones/{number}".to_string().replace("{number}", &number.into().to_string()); + let path = "/project/mock-phones/{number}" + .to_string() + .replace("{number}", &number.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a mock phone by its unique number. Use this endpoint to update the @@ -246,24 +287,29 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/mock-phones/{number}".to_string().replace("{number}", &number.into().to_string()); + let path = "/project/mock-phones/{number}" + .to_string() + .replace("{number}", &number.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a mock phone by its unique number. This endpoint removes the mock /// phone and its OTP configuration from the project. - pub async fn delete_mock_phone( - &self, - number: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_mock_phone(&self, number: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/project/mock-phones/{number}".to_string().replace("{number}", &number.into().to_string()); + let path = "/project/mock-phones/{number}" + .to_string() + .replace("{number}", &number.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all OAuth2 providers supported by the server, along with the @@ -276,7 +322,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -286,7 +335,9 @@ impl Project { let path = "/project/oauth2".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update the OAuth2 server (OIDC provider) configuration. @@ -312,12 +363,21 @@ impl Project { ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("enabled".to_string(), json!(enabled)); - params.insert("authorizationUrl".to_string(), json!(authorization_url.into())); + params.insert( + "authorizationUrl".to_string(), + json!(authorization_url.into()), + ); if let Some(value) = scopes { - params.insert("scopes".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "scopes".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = authorization_details_types { - params.insert("authorizationDetailsTypes".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "authorizationDetailsTypes".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = access_token_duration { params.insert("accessTokenDuration".to_string(), json!(value)); @@ -350,10 +410,16 @@ impl Project { params.insert("deviceCodeDuration".to_string(), json!(value)); } if let Some(value) = default_scopes { - params.insert("defaultScopes".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "defaultScopes".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = installation_scopes { - params.insert("installationScopes".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "installationScopes".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()); @@ -361,7 +427,9 @@ impl Project { let path = "/project/oauth2-server".to_string(); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Amazon configuration. @@ -387,7 +455,9 @@ impl Project { let path = "/project/oauth2/amazon".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Apple configuration. @@ -421,7 +491,9 @@ impl Project { let path = "/project/oauth2/apple".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Appwrite configuration. @@ -447,7 +519,9 @@ impl Project { let path = "/project/oauth2/appwrite".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Auth0 configuration. @@ -477,7 +551,9 @@ impl Project { let path = "/project/oauth2/auth0".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Authentik configuration. @@ -507,7 +583,9 @@ impl Project { let path = "/project/oauth2/authentik".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Autodesk configuration. @@ -533,7 +611,9 @@ impl Project { let path = "/project/oauth2/autodesk".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Bitbucket configuration. @@ -559,7 +639,9 @@ impl Project { let path = "/project/oauth2/bitbucket".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Bitly configuration. @@ -585,7 +667,9 @@ impl Project { let path = "/project/oauth2/bitly".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Box configuration. @@ -611,7 +695,9 @@ impl Project { let path = "/project/oauth2/box".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Dailymotion configuration. @@ -637,7 +723,9 @@ impl Project { let path = "/project/oauth2/dailymotion".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Discord configuration. @@ -663,7 +751,9 @@ impl Project { let path = "/project/oauth2/discord".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Disqus configuration. @@ -689,7 +779,9 @@ impl Project { let path = "/project/oauth2/disqus".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Dropbox configuration. @@ -715,7 +807,9 @@ impl Project { let path = "/project/oauth2/dropbox".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Etsy configuration. @@ -741,7 +835,9 @@ impl Project { let path = "/project/oauth2/etsy".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Facebook configuration. @@ -767,7 +863,9 @@ impl Project { let path = "/project/oauth2/facebook".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Figma configuration. @@ -793,7 +891,9 @@ impl Project { let path = "/project/oauth2/figma".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 FusionAuth configuration. @@ -823,7 +923,9 @@ impl Project { let path = "/project/oauth2/fusionauth".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 GitHub configuration. @@ -849,7 +951,9 @@ impl Project { let path = "/project/oauth2/github".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Gitlab configuration. @@ -879,7 +983,9 @@ impl Project { let path = "/project/oauth2/gitlab".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Google configuration. @@ -909,7 +1015,37 @@ impl Project { let path = "/project/oauth2/google".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Update the project OAuth2 Hugging Face configuration. + pub async fn update_o_auth2_hugging_face( + &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/huggingface".to_string(); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Keycloak configuration. @@ -943,7 +1079,9 @@ impl Project { let path = "/project/oauth2/keycloak".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Kick configuration. @@ -969,7 +1107,9 @@ impl Project { let path = "/project/oauth2/kick".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Linkedin configuration. @@ -995,7 +1135,9 @@ impl Project { let path = "/project/oauth2/linkedin".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Microsoft configuration. @@ -1025,7 +1167,9 @@ impl Project { let path = "/project/oauth2/microsoft".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Notion configuration. @@ -1051,7 +1195,9 @@ impl Project { let path = "/project/oauth2/notion".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Oidc configuration. @@ -1102,7 +1248,9 @@ impl Project { let path = "/project/oauth2/oidc".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Okta configuration. @@ -1136,7 +1284,9 @@ impl Project { let path = "/project/oauth2/okta".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Paypal configuration. @@ -1162,7 +1312,9 @@ impl Project { let path = "/project/oauth2/paypal".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 PaypalSandbox configuration. @@ -1188,7 +1340,9 @@ impl Project { let path = "/project/oauth2/paypalSandbox".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Podio configuration. @@ -1214,7 +1368,9 @@ impl Project { let path = "/project/oauth2/podio".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Salesforce configuration. @@ -1240,7 +1396,9 @@ impl Project { let path = "/project/oauth2/salesforce".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Slack configuration. @@ -1266,7 +1424,9 @@ impl Project { let path = "/project/oauth2/slack".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Spotify configuration. @@ -1292,7 +1452,9 @@ impl Project { let path = "/project/oauth2/spotify".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Stripe configuration. @@ -1318,7 +1480,9 @@ impl Project { let path = "/project/oauth2/stripe".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Tradeshift configuration. @@ -1344,7 +1508,9 @@ impl Project { let path = "/project/oauth2/tradeshift".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Tradeshift Sandbox configuration. @@ -1370,7 +1536,9 @@ impl Project { let path = "/project/oauth2/tradeshiftBox".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Twitch configuration. @@ -1396,7 +1564,9 @@ impl Project { let path = "/project/oauth2/twitch".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 WordPress configuration. @@ -1422,7 +1592,9 @@ impl Project { let path = "/project/oauth2/wordpress".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 X configuration. @@ -1448,7 +1620,9 @@ impl Project { let path = "/project/oauth2/x".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Yahoo configuration. @@ -1474,7 +1648,9 @@ impl Project { let path = "/project/oauth2/yahoo".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Yandex configuration. @@ -1500,7 +1676,9 @@ impl Project { let path = "/project/oauth2/yandex".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Zoho configuration. @@ -1526,7 +1704,9 @@ impl Project { let path = "/project/oauth2/zoho".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the project OAuth2 Zoom configuration. @@ -1552,7 +1732,9 @@ impl Project { let path = "/project/oauth2/zoom".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a single OAuth2 provider configuration. Credential fields (client @@ -1565,9 +1747,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/oauth2/{providerId}".to_string().replace("{providerId}", &provider_id.to_string()); + let path = "/project/oauth2/{providerId}" + .to_string() + .replace("{providerId}", &provider_id.to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all platforms in the project. This endpoint returns an array @@ -1579,7 +1765,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -1589,7 +1778,9 @@ impl Project { let path = "/project/platforms".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Android platform for your project. Use this endpoint to @@ -1611,7 +1802,9 @@ impl Project { let path = "/project/platforms/android".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an Android platform by its unique ID. Use this endpoint to update @@ -1629,9 +1822,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/platforms/android/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/android/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Create a new Apple platform for your project. Use this endpoint to register @@ -1646,14 +1843,19 @@ impl Project { let mut params = HashMap::new(); params.insert("platformId".to_string(), json!(platform_id.into())); params.insert("name".to_string(), json!(name.into())); - params.insert("bundleIdentifier".to_string(), json!(bundle_identifier.into())); + params.insert( + "bundleIdentifier".to_string(), + json!(bundle_identifier.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/platforms/apple".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an Apple platform by its unique ID. Use this endpoint to update the @@ -1666,14 +1868,21 @@ impl Project { ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); - params.insert("bundleIdentifier".to_string(), json!(bundle_identifier.into())); + params.insert( + "bundleIdentifier".to_string(), + json!(bundle_identifier.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/platforms/apple/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/apple/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Create a new Linux platform for your project. Use this endpoint to register @@ -1695,7 +1904,9 @@ impl Project { let path = "/project/platforms/linux".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Linux platform by its unique ID. Use this endpoint to update the @@ -1713,9 +1924,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/platforms/linux/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/linux/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Create a new web platform for your project. Use this endpoint to register a @@ -1737,7 +1952,9 @@ impl Project { let path = "/project/platforms/web".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a web platform by its unique ID. Use this endpoint to update the @@ -1755,9 +1972,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/platforms/web/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/web/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Create a new Windows platform for your project. Use this endpoint to @@ -1772,14 +1993,19 @@ impl Project { let mut params = HashMap::new(); params.insert("platformId".to_string(), json!(platform_id.into())); params.insert("name".to_string(), json!(name.into())); - params.insert("packageIdentifierName".to_string(), json!(package_identifier_name.into())); + params.insert( + "packageIdentifierName".to_string(), + json!(package_identifier_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/platforms/windows".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a Windows platform by its unique ID. Use this endpoint to update the @@ -1792,14 +2018,21 @@ impl Project { ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); - params.insert("packageIdentifierName".to_string(), json!(package_identifier_name.into())); + params.insert( + "packageIdentifierName".to_string(), + json!(package_identifier_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/platforms/windows/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/windows/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Get a platform by its unique ID. This endpoint returns the platform's @@ -1812,9 +2045,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/platforms/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a platform by its unique ID. This endpoint removes the platform and @@ -1827,9 +2064,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/project/platforms/{platformId}".to_string().replace("{platformId}", &platform_id.into().to_string()); + let path = "/project/platforms/{platformId}" + .to_string() + .replace("{platformId}", &platform_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all project policies and their current configuration. @@ -1840,7 +2081,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -1850,7 +2094,9 @@ impl Project { let path = "/project/policies".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Configures if aliased emails such as subaddresses and emails with suffixes @@ -1867,7 +2113,9 @@ impl Project { let path = "/project/policies/deny-aliased-email".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Configures if only corporate email addresses (non-free and non-disposable @@ -1884,7 +2132,9 @@ impl Project { let path = "/project/policies/deny-corporate-email".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Configures if disposable emails from known temporary domains are denied @@ -1901,7 +2151,9 @@ impl Project { let path = "/project/policies/deny-disposable-email".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Configures if emails from free providers such as Gmail or Yahoo are denied @@ -1918,7 +2170,9 @@ impl Project { let path = "/project/policies/deny-free-email".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updating this policy allows you to control if team members can see other @@ -1958,7 +2212,9 @@ impl Project { let path = "/project/policies/membership-privacy".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updating this policy allows you to control which factors users can use to @@ -1992,7 +2248,9 @@ impl Project { let path = "/project/policies/mfa-factors".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updating this policy allows you to control if new passwords are checked @@ -2010,14 +2268,16 @@ impl Project { let path = "/project/policies/password-dictionary".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updates one of password strength policies. Based on total length /// configured, previous password hashes are stored, and users cannot choose a /// new password that is already stored in the passwird history list, when /// updating an user password, or setting new one through password recovery. - /// + /// /// Keep in mind, while password history policy is disabled, the history is not /// being stored. Enabling the policy will not have any history on existing /// users, and it will only start to collect and enforce the policy on password @@ -2036,7 +2296,9 @@ impl Project { let path = "/project/policies/password-history".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updating this policy allows you to control if password strength is checked @@ -2055,7 +2317,9 @@ impl Project { let path = "/project/policies/password-personal-data".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the password strength requirements for users in the project. @@ -2089,7 +2353,9 @@ impl Project { let path = "/project/policies/password-strength".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updating this policy allows you to control if email alert is sent upon @@ -2109,7 +2375,9 @@ impl Project { let path = "/project/policies/session-alert".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update maximum duration how long sessions created within a project should @@ -2126,7 +2394,9 @@ impl Project { let path = "/project/policies/session-duration".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Updating this policy allows you to control if existing sessions should be @@ -2144,7 +2414,9 @@ impl Project { let path = "/project/policies/session-invalidation".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the maximum number of sessions allowed per user. When the limit is @@ -2161,7 +2433,9 @@ impl Project { let path = "/project/policies/session-limit".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the maximum number of users in the project. When the limit is hit or @@ -2181,7 +2455,9 @@ impl Project { let path = "/project/policies/user-limit".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a policy by its unique ID. This endpoint returns the current @@ -2194,9 +2470,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/policies/{policyId}".to_string().replace("{policyId}", &policy_id.to_string()); + let path = "/project/policies/{policyId}" + .to_string() + .replace("{policyId}", &policy_id.to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update properties of a specific protocol. Use this endpoint to enable or @@ -2212,9 +2492,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/protocols/{protocolId}".to_string().replace("{protocolId}", &protocol_id.to_string()); + let path = "/project/protocols/{protocolId}" + .to_string() + .replace("{protocolId}", &protocol_id.to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update properties of a specific service. Use this endpoint to enable or @@ -2230,9 +2514,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/services/{serviceId}".to_string().replace("{serviceId}", &service_id.to_string()); + let path = "/project/services/{serviceId}" + .to_string() + .replace("{serviceId}", &service_id.to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the SMTP configuration for your project. Use this endpoint to @@ -2289,7 +2577,9 @@ impl Project { let path = "/project/smtp".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Send a test email to verify SMTP configuration. @@ -2298,13 +2588,21 @@ impl Project { emails: impl IntoIterator>, ) -> crate::error::Result<()> { let mut params = HashMap::new(); - params.insert("emails".to_string(), json!(emails.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "emails".to_string(), + json!(emails + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); let path = "/project/smtp/tests".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all custom email templates configured for the project. This @@ -2317,7 +2615,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -2327,7 +2628,9 @@ impl Project { let path = "/project/templates/email".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a custom email template for the specified locale and type. Use this @@ -2373,7 +2676,9 @@ impl Project { let path = "/project/templates/email".to_string(); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a custom email template for the specified locale and type. This @@ -2391,9 +2696,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/templates/email/{templateId}".to_string().replace("{templateId}", &template_id.to_string()); + let path = "/project/templates/email/{templateId}" + .to_string() + .replace("{templateId}", &template_id.to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all project environment variables. @@ -2404,7 +2713,10 @@ impl Project { ) -> 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::>())); + 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)); @@ -2414,7 +2726,9 @@ impl Project { let path = "/project/variables".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new project environment variable. These variables can be accessed @@ -2439,7 +2753,9 @@ impl Project { let path = "/project/variables".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a variable by its unique ID. @@ -2451,9 +2767,13 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/variables/{variableId}".to_string().replace("{variableId}", &variable_id.into().to_string()); + let path = "/project/variables/{variableId}" + .to_string() + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update variable by its unique ID. @@ -2478,9 +2798,13 @@ impl Project { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/project/variables/{variableId}".to_string().replace("{variableId}", &variable_id.into().to_string()); + let path = "/project/variables/{variableId}" + .to_string() + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a variable by its unique ID. @@ -2492,11 +2816,14 @@ impl Project { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/project/variables/{variableId}".to_string().replace("{variableId}", &variable_id.into().to_string()); + let path = "/project/variables/{variableId}" + .to_string() + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Project { diff --git a/src/services/proxy.rs b/src/services/proxy.rs index 45e29d4..2507b73 100644 --- a/src/services/proxy.rs +++ b/src/services/proxy.rs @@ -15,7 +15,9 @@ pub struct Proxy { impl Proxy { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -24,7 +26,7 @@ impl Proxy { /// Create a new CDN cache invalidation for a domain. Executes a hard purge of /// cached content. - /// + /// /// Depending on type, the invalidation purges a single cache tag, a single URL /// path, or all cached content for the domain. pub async fn create_invalidation( @@ -45,7 +47,9 @@ impl Proxy { let path = "/proxy/invalidations".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the proxy rules. You can use the query params to filter @@ -57,7 +61,10 @@ impl Proxy { ) -> 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::>())); + 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)); @@ -67,11 +74,13 @@ impl Proxy { let path = "/proxy/rules".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new proxy rule for serving Appwrite's API on custom domain. - /// + /// /// Rule ID is automatically generated as MD5 hash of a rule domain for /// performance purposes. pub async fn create_api_rule( @@ -86,11 +95,13 @@ impl Proxy { let path = "/proxy/rules/api".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new proxy rule for executing Appwrite Function on custom domain. - /// + /// /// Rule ID is automatically generated as MD5 hash of a rule domain for /// performance purposes. pub async fn create_function_rule( @@ -111,12 +122,14 @@ impl Proxy { let path = "/proxy/rules/function".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new proxy rule for to redirect from custom domain to another /// domain. - /// + /// /// Rule ID is automatically generated as MD5 hash of a rule domain for /// performance purposes. pub async fn create_redirect_rule( @@ -139,11 +152,13 @@ impl Proxy { let path = "/proxy/rules/redirect".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new proxy rule for serving Appwrite Site on custom domain. - /// + /// /// Rule ID is automatically generated as MD5 hash of a rule domain for /// performance purposes. pub async fn create_site_rule( @@ -164,7 +179,9 @@ impl Proxy { let path = "/proxy/rules/site".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a proxy rule by its unique ID. @@ -176,23 +193,28 @@ impl Proxy { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/proxy/rules/{ruleId}".to_string().replace("{ruleId}", &rule_id.into().to_string()); + let path = "/proxy/rules/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a proxy rule by its unique ID. - pub async fn delete_rule( - &self, - rule_id: impl Into, - ) -> crate::error::Result<()> { + 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()); - let path = "/proxy/rules/{ruleId}".to_string().replace("{ruleId}", &rule_id.into().to_string()); + let path = "/proxy/rules/{ruleId}" + .to_string() + .replace("{ruleId}", &rule_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// If not succeeded yet, retry verification process of a proxy rule domain. @@ -208,11 +230,14 @@ impl Proxy { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/proxy/rules/{ruleId}/status".to_string().replace("{ruleId}", &rule_id.into().to_string()); + let path = "/proxy/rules/{ruleId}/status" + .to_string() + .replace("{ruleId}", &rule_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Proxy { diff --git a/src/services/sites.rs b/src/services/sites.rs index 9b4e053..86dcaea 100644 --- a/src/services/sites.rs +++ b/src/services/sites.rs @@ -14,7 +14,9 @@ pub struct Sites { impl Sites { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -31,7 +33,10 @@ impl Sites { ) -> 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::>())); + 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)); @@ -44,7 +49,9 @@ impl Sites { let path = "/sites".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new site. @@ -74,6 +81,7 @@ impl Sites { build_specification: Option<&str>, runtime_specification: Option<&str>, deployment_retention: Option, + scopes: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("siteId".to_string(), json!(site_id.into())); @@ -123,10 +131,16 @@ impl Sites { params.insert("providerRootDirectory".to_string(), json!(value)); } if let Some(value) = provider_branches { - params.insert("providerBranches".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerBranches".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = provider_paths { - params.insert("providerPaths".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerPaths".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = build_specification { params.insert("buildSpecification".to_string(), json!(value)); @@ -137,27 +151,32 @@ impl Sites { if let Some(value) = deployment_retention { params.insert("deploymentRetention".to_string(), json!(value)); } + if let Some(value) = scopes { + params.insert("scopes".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 = "/sites".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all frameworks that are currently available on the server /// instance. - pub async fn list_frameworks( - &self, - ) -> crate::error::Result { + pub async fn list_frameworks(&self) -> crate::error::Result { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); let path = "/sites/frameworks".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// List allowed site specifications for this instance. @@ -174,7 +193,9 @@ impl Sites { let path = "/sites/specifications".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a site by its unique ID. @@ -186,9 +207,13 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update site by its unique ID. @@ -218,6 +243,7 @@ impl Sites { build_specification: Option<&str>, runtime_specification: Option<&str>, deployment_retention: Option, + scopes: Option>, ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); @@ -268,10 +294,16 @@ impl Sites { params.insert("providerRootDirectory".to_string(), json!(value)); } if let Some(value) = provider_branches { - params.insert("providerBranches".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerBranches".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = provider_paths { - params.insert("providerPaths".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "providerPaths".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = build_specification { params.insert("buildSpecification".to_string(), json!(value)); @@ -282,27 +314,35 @@ impl Sites { if let Some(value) = deployment_retention { params.insert("deploymentRetention".to_string(), json!(value)); } + if let Some(value) = scopes { + params.insert("scopes".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 = "/sites/{siteId}".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a site by its unique ID. - pub async fn delete( - &self, - site_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, site_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the site active deployment. Use this endpoint to switch the code @@ -318,9 +358,13 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployment".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/deployment" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the site's code deployments. You can use the query params @@ -334,7 +378,10 @@ impl Sites { ) -> 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::>())); + 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)); @@ -345,9 +392,13 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/deployments" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new site code deployment. Use this endpoint to upload a new @@ -376,12 +427,19 @@ impl Sites { params.insert("activate".to_string(), json!(value)); } let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "multipart/form-data".to_string()); + api_headers.insert( + "content-type".to_string(), + "multipart/form-data".to_string(), + ); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/deployments" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.file_upload(&path, Some(api_headers), params, "code", code, None).await + self.client + .file_upload(&path, Some(api_headers), params, "code", code, None) + .await } /// Create a new build for an existing site deployment. This endpoint allows @@ -400,13 +458,17 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments/duplicate".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/deployments/duplicate" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a deployment based on a template. - /// + /// /// Use this endpoint with combination of /// [listTemplates](https://appwrite.io/docs/products/sites/templates) to find /// the template details. @@ -434,13 +496,17 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments/template".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/deployments/template" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a deployment when a site is connected to VCS. - /// + /// /// This endpoint lets you create deployment from a branch, commit, or a tag. pub async fn create_vcs_deployment( &self, @@ -459,9 +525,13 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments/vcs".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/deployments/vcs" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a site deployment by its unique ID. @@ -474,9 +544,14 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments/{deploymentId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/sites/{siteId}/deployments/{deploymentId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a site deployment by its unique ID. @@ -489,9 +564,14 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments/{deploymentId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/sites/{siteId}/deployments/{deploymentId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a site deployment content by its unique ID. The endpoint response @@ -514,9 +594,14 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); - let path = "/sites/{siteId}/deployments/{deploymentId}/download".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/sites/{siteId}/deployments/{deploymentId}/download" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Cancel an ongoing site deployment build. If the build is already in @@ -534,9 +619,14 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/deployments/{deploymentId}/status".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{deploymentId}", &deployment_id.into().to_string()); + let path = "/sites/{siteId}/deployments/{deploymentId}/status" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{deploymentId}", &deployment_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all site logs. You can use the query params to filter your @@ -549,7 +639,10 @@ impl Sites { ) -> 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::>())); + 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)); @@ -557,9 +650,13 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/logs".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/logs" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a site request log by its unique ID. @@ -572,9 +669,14 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/logs/{logId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{logId}", &log_id.into().to_string()); + let path = "/sites/{siteId}/logs/{logId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{logId}", &log_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a site log by its unique ID. @@ -588,9 +690,14 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/logs/{logId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{logId}", &log_id.into().to_string()); + let path = "/sites/{siteId}/logs/{logId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{logId}", &log_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all variables of a specific site. @@ -602,7 +709,10 @@ impl Sites { ) -> 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::>())); + 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)); @@ -610,9 +720,13 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/variables".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/variables" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new site variable. These variables can be accessed during build @@ -636,9 +750,13 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/variables".to_string().replace("{siteId}", &site_id.into().to_string()); + let path = "/sites/{siteId}/variables" + .to_string() + .replace("{siteId}", &site_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a variable by its unique ID. @@ -651,9 +769,14 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/variables/{variableId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{variableId}", &variable_id.into().to_string()); + let path = "/sites/{siteId}/variables/{variableId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update variable by its unique ID. @@ -679,9 +802,14 @@ impl Sites { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/variables/{variableId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{variableId}", &variable_id.into().to_string()); + let path = "/sites/{siteId}/variables/{variableId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a variable by its unique ID. @@ -694,11 +822,15 @@ impl Sites { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/sites/{siteId}/variables/{variableId}".to_string().replace("{siteId}", &site_id.into().to_string()).replace("{variableId}", &variable_id.into().to_string()); + let path = "/sites/{siteId}/variables/{variableId}" + .to_string() + .replace("{siteId}", &site_id.into().to_string()) + .replace("{variableId}", &variable_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Sites { diff --git a/src/services/storage.rs b/src/services/storage.rs index 4c38f36..4736eaf 100644 --- a/src/services/storage.rs +++ b/src/services/storage.rs @@ -14,7 +14,9 @@ pub struct Storage { impl Storage { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -31,7 +33,10 @@ impl Storage { ) -> 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::>())); + 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)); @@ -44,7 +49,9 @@ impl Storage { let path = "/storage/buckets".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new storage bucket. @@ -67,7 +74,10 @@ impl Storage { params.insert("bucketId".to_string(), json!(bucket_id.into())); params.insert("name".to_string(), json!(name.into())); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = file_security { params.insert("fileSecurity".to_string(), json!(value)); @@ -79,7 +89,10 @@ impl Storage { params.insert("maximumFileSize".to_string(), json!(value)); } if let Some(value) = allowed_file_extensions { - params.insert("allowedFileExtensions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "allowedFileExtensions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = compression { params.insert("compression".to_string(), json!(value)); @@ -99,7 +112,9 @@ impl Storage { let path = "/storage/buckets".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a storage bucket by its unique ID. This endpoint response returns a @@ -112,9 +127,13 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()); + let path = "/storage/buckets/{bucketId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a storage bucket by its unique ID. @@ -136,7 +155,10 @@ impl Storage { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = file_security { params.insert("fileSecurity".to_string(), json!(value)); @@ -148,7 +170,10 @@ impl Storage { params.insert("maximumFileSize".to_string(), json!(value)); } if let Some(value) = allowed_file_extensions { - params.insert("allowedFileExtensions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "allowedFileExtensions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = compression { params.insert("compression".to_string(), json!(value)); @@ -166,23 +191,28 @@ impl Storage { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()); + let path = "/storage/buckets/{bucketId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a storage bucket by its unique ID. - pub async fn delete_bucket( - &self, - bucket_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_bucket(&self, bucket_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()); + let path = "/storage/buckets/{bucketId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the user files. You can use the query params to filter @@ -196,7 +226,10 @@ impl Storage { ) -> 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::>())); + 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)); @@ -207,26 +240,30 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}/files".to_string().replace("{bucketId}", &bucket_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server /// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) /// API or directly from your Appwrite console. - /// + /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) /// header to send a partial request with a maximum supported chunk of `5MB`. /// The `content-range` header values should always be in bytes. - /// + /// /// When the first request is sent, the server will return the **File** object, /// and the subsequent part request must include the file's **id** in /// `x-appwrite-id` header to allow the server to know that the partial upload /// is for the existing file and not for a new one. - /// + /// /// If you're creating a new file using one of the Appwrite SDKs, all the /// chunking logic will be managed by the SDK internally. pub async fn create_file( @@ -241,18 +278,35 @@ impl Storage { let mut params = HashMap::new(); params.insert("fileId".to_string(), json!(file_id_str)); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = folder { params.insert("folder".to_string(), json!(value)); } let mut api_headers = HashMap::new(); - api_headers.insert("content-type".to_string(), "multipart/form-data".to_string()); + api_headers.insert( + "content-type".to_string(), + "multipart/form-data".to_string(), + ); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}/files".to_string().replace("{bucketId}", &bucket_id.into().to_string()); - - self.client.file_upload(&path, Some(api_headers), params, "file", file, Some(file_id_str)).await + let path = "/storage/buckets/{bucketId}/files" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()); + + self.client + .file_upload( + &path, + Some(api_headers), + params, + "file", + file, + Some(file_id_str), + ) + .await } /// Get a file by its unique ID. This endpoint response returns a JSON object @@ -266,9 +320,14 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}/files/{fileId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files/{fileId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a file by its unique ID. Only users with write permissions have @@ -285,15 +344,23 @@ impl Storage { params.insert("name".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".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 = "/storage/buckets/{bucketId}/files/{fileId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files/{fileId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a file by its unique ID. Only users with write permissions have @@ -307,9 +374,14 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/storage/buckets/{bucketId}/files/{fileId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files/{fileId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a file content by its unique ID. The endpoint response return with a @@ -328,9 +400,14 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); - let path = "/storage/buckets/{bucketId}/files/{fileId}/download".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files/{fileId}/download" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a file preview image. Currently, this method supports preview for image @@ -396,9 +473,14 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "image/*".to_string()); - let path = "/storage/buckets/{bucketId}/files/{fileId}/preview".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files/{fileId}/preview" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a file content by its unique ID. This endpoint is similar to the @@ -417,11 +499,15 @@ impl Storage { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "*/*".to_string()); - let path = "/storage/buckets/{bucketId}/files/{fileId}/view".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/storage/buckets/{bucketId}/files/{fileId}/view" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call_bytes(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call_bytes(Method::GET, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Storage { diff --git a/src/services/tables_db.rs b/src/services/tables_db.rs index 97d2c6a..3b41044 100644 --- a/src/services/tables_db.rs +++ b/src/services/tables_db.rs @@ -15,7 +15,9 @@ pub struct TablesDB { impl TablesDB { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -32,7 +34,10 @@ impl TablesDB { ) -> 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::>())); + 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)); @@ -45,7 +50,9 @@ impl TablesDB { let path = "/tablesdb".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Database. @@ -79,7 +86,9 @@ impl TablesDB { let path = "/tablesdb".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List the dedicated database specifications available on the current plan. @@ -94,7 +103,9 @@ impl TablesDB { let path = "/tablesdb/specifications".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// List transactions across all databases. @@ -104,14 +115,19 @@ impl TablesDB { ) -> 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::>())); + 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 path = "/tablesdb/transactions".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new transaction. @@ -129,7 +145,9 @@ impl TablesDB { let path = "/tablesdb/transactions".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a transaction by its unique ID. @@ -141,9 +159,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/transactions/{transactionId}".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/tablesdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a transaction, to either commit or roll back its operations. @@ -164,9 +186,13 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/transactions/{transactionId}".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/tablesdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a transaction by its unique ID. @@ -178,9 +204,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tablesdb/transactions/{transactionId}".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/tablesdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Create multiple operations in a single transaction. @@ -197,9 +227,13 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/transactions/{transactionId}/operations".to_string().replace("{transactionId}", &transaction_id.into().to_string()); + let path = "/tablesdb/transactions/{transactionId}/operations" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a database by its unique ID. This endpoint response returns a JSON @@ -212,9 +246,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a database by its unique ID. @@ -247,31 +285,40 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. - pub async fn delete( - &self, - database_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Trigger a manual failover for a dedicated database with high availability /// enabled. Promotes a replica to primary. The failover runs asynchronously; /// poll the database document for status updates. A database left - /// mid-operation by a failover that did not finish also accepts this call as a - /// repair, provided `targetReplicaId` names the member to promote. + /// mid-operation also accepts this call as a repair once nothing is driving + /// the operation it is stuck in. Repairing a failover that did not finish, a + /// `failed` database, a stranded upgrade or migrate, or a stranded compute + /// resize additionally requires `targetReplicaId` to name the member to + /// promote, because the default target may be the member that operation + /// already promoted. pub async fn create_failover( &self, database_id: impl Into, @@ -285,9 +332,13 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/failovers".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/failovers" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List the dedicated migrations for a TablesDB database. A database has at @@ -300,9 +351,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/migrations".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/migrations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Start migrating a serverless TablesDB database onto a dedicated MySQL @@ -323,9 +378,13 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/migrations".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/migrations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a single dedicated migration for a TablesDB database by its ID. @@ -338,9 +397,14 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/migrations/{migrationId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{migrationId}", &migration_id.into().to_string()); + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{migrationId}", &migration_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Abort an in-flight TablesDB dedicated migration. Only allowed before @@ -355,9 +419,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/migrations/{migrationId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{migrationId}", &migration_id.into().to_string()); + let path = "/tablesdb/{databaseId}/migrations/{migrationId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{migrationId}", &migration_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Cut a verified TablesDB migration over to its dedicated compute. Only @@ -376,9 +445,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/migrations/{migrationId}/cutover".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{migrationId}", &migration_id.into().to_string()); + let path = "/tablesdb/{databaseId}/migrations/{migrationId}/cutover" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{migrationId}", &migration_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// List the lifecycle operations recorded for a dedicated database, newest @@ -405,9 +479,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/operations".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/operations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get high availability status for a dedicated database. Returns replica @@ -420,9 +498,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/replicas".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/replicas" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get real-time health and status information for a dedicated database. @@ -436,9 +518,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/status".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/status" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all tables that belong to the provided databaseId. You can @@ -452,7 +538,10 @@ impl TablesDB { ) -> 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::>())); + 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)); @@ -463,9 +552,13 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Table. Before using this route, you should create a new @@ -488,7 +581,10 @@ impl TablesDB { params.insert("tableId".to_string(), json!(table_id.into())); params.insert("name".to_string(), json!(name.into())); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = row_security { params.insert("rowSecurity".to_string(), json!(value)); @@ -506,9 +602,13 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables".to_string().replace("{databaseId}", &database_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a table by its unique ID. This endpoint response returns a JSON object @@ -522,9 +622,14 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a table by its unique ID. @@ -544,7 +649,10 @@ impl TablesDB { params.insert("name".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = row_security { params.insert("rowSecurity".to_string(), json!(value)); @@ -559,9 +667,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a table by its unique ID. Only users with write permissions have @@ -575,9 +688,14 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List columns in the table. @@ -590,7 +708,10 @@ impl TablesDB { ) -> 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::>())); + 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)); @@ -598,9 +719,14 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a bigint column. Optionally, minimum and maximum values can be @@ -636,9 +762,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a bigint column. Changing the `default` value will not update @@ -673,9 +804,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a boolean column. @@ -701,9 +838,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a boolean column. Changing the `default` value will not update @@ -729,9 +871,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a date time column according to the ISO 8601 standard. @@ -757,9 +905,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a date time column. Changing the `default` value will not update @@ -785,9 +938,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create an email column. @@ -813,9 +972,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an email column. Changing the `default` value will not update @@ -841,9 +1005,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create an enumeration column. The `elements` param acts as a white-list of @@ -861,7 +1031,13 @@ impl TablesDB { ) -> crate::error::Result { let mut params = HashMap::new(); params.insert("key".to_string(), json!(key.into())); - params.insert("elements".to_string(), json!(elements.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "elements".to_string(), + json!(elements + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); params.insert("required".to_string(), json!(required)); if let Some(value) = default { params.insert("default".to_string(), json!(value)); @@ -873,9 +1049,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an enum column. Changing the `default` value will not update already @@ -892,7 +1073,13 @@ impl TablesDB { new_key: Option<&str>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("elements".to_string(), json!(elements.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "elements".to_string(), + json!(elements + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); params.insert("required".to_string(), json!(required)); if let Some(value) = default { params.insert("default".to_string(), json!(value)); @@ -904,9 +1091,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a float column. Optionally, minimum and maximum values can be @@ -942,9 +1135,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a float column. Changing the `default` value will not update already @@ -979,9 +1177,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create an integer column. Optionally, minimum and maximum values can be @@ -1017,9 +1221,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an integer column. Changing the `default` value will not update @@ -1054,9 +1263,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create IP address column. @@ -1082,9 +1297,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an ip column. Changing the `default` value will not update already @@ -1110,9 +1330,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a geometric line column. @@ -1134,9 +1360,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a line column. Changing the `default` value will not update already @@ -1162,9 +1393,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a longtext column. @@ -1195,9 +1432,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a longtext column. Changing the `default` value will not update @@ -1223,9 +1465,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a mediumtext column. @@ -1256,9 +1504,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a mediumtext column. Changing the `default` value will not update @@ -1284,9 +1537,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a geometric point column. @@ -1308,9 +1567,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a point column. Changing the `default` value will not update already @@ -1336,9 +1600,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a geometric polygon column. @@ -1360,9 +1630,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a polygon column. Changing the `default` value will not update @@ -1388,9 +1663,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create relationship column. [Learn more about relationship @@ -1426,9 +1707,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/relationship" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a string column. @@ -1461,9 +1747,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a string column. Changing the `default` value will not update @@ -1494,9 +1785,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a text column. @@ -1527,9 +1824,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a text column. Changing the `default` value will not update already @@ -1555,9 +1857,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a URL column. @@ -1583,9 +1891,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update an url column. Changing the `default` value will not update already @@ -1611,9 +1924,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Create a varchar column. @@ -1646,9 +1965,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update a varchar column. Changing the `default` value will not update @@ -1679,9 +2003,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get column by ID. @@ -1695,9 +2025,15 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Deletes a column. @@ -1711,9 +2047,15 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update relationship column. [Learn more about relationship @@ -1737,9 +2079,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// List indexes on the table. @@ -1752,7 +2100,10 @@ impl TablesDB { ) -> 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::>())); + 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)); @@ -1760,9 +2111,14 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Creates an index on the columns listed. Your index should include all the @@ -1782,7 +2138,13 @@ impl TablesDB { let mut params = HashMap::new(); params.insert("key".to_string(), json!(key.into())); params.insert("type".to_string(), json!(r#type)); - params.insert("columns".to_string(), json!(columns.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "columns".to_string(), + json!(columns + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); if let Some(value) = orders { params.insert("orders".to_string(), json!(value)); } @@ -1793,9 +2155,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get index by ID. @@ -1809,9 +2176,15 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an index. @@ -1825,9 +2198,15 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{key}", &key.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{key}", &key.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a list of all the user's rows in a given table. You can use the query @@ -1843,7 +2222,10 @@ impl TablesDB { ) -> 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::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1857,9 +2239,14 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new Row. Before using this route, you should create a new table @@ -1879,7 +2266,10 @@ impl TablesDB { params.insert("rowId".to_string(), json!(row_id.into())); params.insert("data".to_string(), json!(data)); if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1888,9 +2278,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create new Rows. Before using this route, you should create a new table @@ -1913,9 +2308,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create or update Rows. Before using this route, you should create a new @@ -1938,9 +2338,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Update all rows that match your queries, if no queries are submitted then @@ -1958,7 +2363,10 @@ impl TablesDB { params.insert("data".to_string(), json!(value)); } if let Some(value) = queries { - params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1967,9 +2375,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Bulk delete rows using queries, if no queries are passed then all rows are @@ -1983,7 +2396,10 @@ impl TablesDB { ) -> 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::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -1992,9 +2408,14 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a row by its unique ID. This endpoint response returns a JSON object @@ -2009,7 +2430,10 @@ impl TablesDB { ) -> 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::>())); + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -2017,9 +2441,15 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{rowId}", &row_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{rowId}", &row_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create or update a Row. Before using this route, you should create a new @@ -2040,7 +2470,10 @@ impl TablesDB { params.insert("data".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -2049,9 +2482,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{rowId}", &row_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{rowId}", &row_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Update a row by its unique ID. Using the patch method you can pass only @@ -2070,7 +2509,10 @@ impl TablesDB { params.insert("data".to_string(), json!(value)); } if let Some(value) = permissions { - params.insert("permissions".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); } if let Some(value) = transaction_id { params.insert("transactionId".to_string(), json!(value)); @@ -2079,9 +2521,15 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{rowId}", &row_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{rowId}", &row_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a row by its unique ID. @@ -2099,9 +2547,15 @@ impl TablesDB { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{rowId}", &row_id.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{rowId}", &row_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Decrement a specific column of a row by a given value. @@ -2130,9 +2584,16 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{rowId}", &row_id.into().to_string()).replace("{column}", &column.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{rowId}", &row_id.into().to_string()) + .replace("{column}", &column.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Increment a specific column of a row by a given value. @@ -2161,11 +2622,17 @@ impl TablesDB { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment".to_string().replace("{databaseId}", &database_id.into().to_string()).replace("{tableId}", &table_id.into().to_string()).replace("{rowId}", &row_id.into().to_string()).replace("{column}", &column.into().to_string()); + let path = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{tableId}", &table_id.into().to_string()) + .replace("{rowId}", &row_id.into().to_string()) + .replace("{column}", &column.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for TablesDB { diff --git a/src/services/teams.rs b/src/services/teams.rs index decc256..62a9fc3 100644 --- a/src/services/teams.rs +++ b/src/services/teams.rs @@ -15,7 +15,9 @@ pub struct Teams { impl Teams { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -32,7 +34,10 @@ impl Teams { ) -> 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::>())); + 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)); @@ -45,7 +50,9 @@ impl Teams { let path = "/teams".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new team. The user who creates the team will automatically be @@ -61,7 +68,10 @@ impl Teams { params.insert("teamId".to_string(), json!(team_id.into())); params.insert("name".to_string(), json!(name.into())); if let Some(value) = roles { - params.insert("roles".to_string(), json!(value.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "roles".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()); @@ -69,7 +79,9 @@ impl Teams { let path = "/teams".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a team by its ID. All team members have read access for this resource. @@ -81,9 +93,13 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update the team's name by its unique ID. @@ -98,24 +114,29 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a team using its ID. Only team members with the owner role can /// delete the team. - pub async fn delete( - &self, - team_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, team_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// List app installations on a team. Any team member can read installations. @@ -127,7 +148,10 @@ impl Teams { ) -> 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::>())); + 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)); @@ -135,9 +159,13 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/installations".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}/installations" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Install an app on a team. When authenticated as a user, only team members @@ -159,9 +187,13 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/installations".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}/installations" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get an app installation on a team by its unique ID. Any team member can @@ -175,9 +207,14 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/installations/{installationId}".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{installationId}", &installation_id.into().to_string()); + let path = "/teams/{teamId}/installations/{installationId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update an app installation on a team. Only team members with the owner role @@ -198,9 +235,14 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/installations/{installationId}".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{installationId}", &installation_id.into().to_string()); + let path = "/teams/{teamId}/installations/{installationId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Uninstall an app from a team by its installation ID. Only team members with @@ -216,9 +258,14 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/installations/{installationId}".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{installationId}", &installation_id.into().to_string()); + let path = "/teams/{teamId}/installations/{installationId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{installationId}", &installation_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to list a team's members using the team's ID. All team @@ -233,7 +280,10 @@ impl Teams { ) -> 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::>())); + 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)); @@ -244,9 +294,13 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/memberships".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}/memberships" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Invite a new member to join your team. Provide an ID for existing users, or @@ -255,16 +309,16 @@ impl Teams { /// team to the invited user, and an account will be created for them if one /// doesn't exist. If initiated from a Server SDK, the new member will be added /// automatically to the team. - /// + /// /// You only need to provide one of a user ID, email, or phone number. Appwrite /// will prioritize accepting the user ID > email > phone number if you provide /// more than one of these parameters. - /// + /// /// Use the `url` parameter to redirect the user from the invitation email to /// your app. After the user is redirected, use the [Update Team Membership /// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) /// endpoint to allow the user to accept the invitation to the team. - /// + /// /// Please note that to avoid a [Redirect /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have @@ -290,7 +344,10 @@ impl Teams { if let Some(value) = phone { params.insert("phone".to_string(), json!(value)); } - params.insert("roles".to_string(), json!(roles.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "roles".to_string(), + json!(roles.into_iter().map(|s| s.into()).collect::>()), + ); if let Some(value) = url { params.insert("url".to_string(), json!(value)); } @@ -301,9 +358,13 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/memberships".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}/memberships" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a team member by the membership unique id. All team members have read @@ -318,9 +379,14 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/memberships/{membershipId}".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{membershipId}", &membership_id.into().to_string()); + let path = "/teams/{teamId}/memberships/{membershipId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Modify the roles of a team member. Only team members with the owner role @@ -333,14 +399,22 @@ impl Teams { roles: impl IntoIterator>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("roles".to_string(), json!(roles.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "roles".to_string(), + json!(roles.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 = "/teams/{teamId}/memberships/{membershipId}".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{membershipId}", &membership_id.into().to_string()); + let path = "/teams/{teamId}/memberships/{membershipId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// This endpoint allows a user to leave a team or for a team owner to delete @@ -355,15 +429,20 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/memberships/{membershipId}".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{membershipId}", &membership_id.into().to_string()); + let path = "/teams/{teamId}/memberships/{membershipId}" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to allow a user to accept an invitation to join a team /// after being redirected back to your app from the invitation email received /// by the user. - /// + /// /// If the request is successful, a session for the user is automatically /// created. pub async fn update_membership_status( @@ -380,9 +459,14 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/memberships/{membershipId}/status".to_string().replace("{teamId}", &team_id.into().to_string()).replace("{membershipId}", &membership_id.into().to_string()); + let path = "/teams/{teamId}/memberships/{membershipId}/status" + .to_string() + .replace("{teamId}", &team_id.into().to_string()) + .replace("{membershipId}", &membership_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get the team's shared preferences by its unique ID. If a preference doesn't @@ -396,9 +480,13 @@ impl Teams { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/prefs".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}/prefs" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update the team's preferences by its unique ID. The object you pass is @@ -415,11 +503,14 @@ impl Teams { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/teams/{teamId}/prefs".to_string().replace("{teamId}", &team_id.into().to_string()); + let path = "/teams/{teamId}/prefs" + .to_string() + .replace("{teamId}", &team_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Teams { diff --git a/src/services/tokens.rs b/src/services/tokens.rs index 5ec769e..43b9063 100644 --- a/src/services/tokens.rs +++ b/src/services/tokens.rs @@ -15,7 +15,9 @@ pub struct Tokens { impl Tokens { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -33,7 +35,10 @@ impl Tokens { ) -> 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::>())); + 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)); @@ -41,9 +46,14 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tokens/buckets/{bucketId}/files/{fileId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/tokens/buckets/{bucketId}/files/{fileId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new token. A token is linked to a file. Token can be passed as a @@ -62,9 +72,14 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tokens/buckets/{bucketId}/files/{fileId}".to_string().replace("{bucketId}", &bucket_id.into().to_string()).replace("{fileId}", &file_id.into().to_string()); + let path = "/tokens/buckets/{bucketId}/files/{fileId}" + .to_string() + .replace("{bucketId}", &bucket_id.into().to_string()) + .replace("{fileId}", &file_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a token by its unique ID. @@ -76,9 +91,13 @@ impl Tokens { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tokens/{tokenId}".to_string().replace("{tokenId}", &token_id.into().to_string()); + let path = "/tokens/{tokenId}" + .to_string() + .replace("{tokenId}", &token_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a token by its unique ID. Use this endpoint to update a token's @@ -96,25 +115,29 @@ impl Tokens { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/tokens/{tokenId}".to_string().replace("{tokenId}", &token_id.into().to_string()); + let path = "/tokens/{tokenId}" + .to_string() + .replace("{tokenId}", &token_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a token by its unique ID. - pub async fn delete( - &self, - token_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, token_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/tokens/{tokenId}".to_string().replace("{tokenId}", &token_id.into().to_string()); + let path = "/tokens/{tokenId}" + .to_string() + .replace("{tokenId}", &token_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Tokens { diff --git a/src/services/users.rs b/src/services/users.rs index 0d36f19..f381a1e 100644 --- a/src/services/users.rs +++ b/src/services/users.rs @@ -14,7 +14,9 @@ pub struct Users { impl Users { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -31,7 +33,10 @@ impl Users { ) -> 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::>())); + 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)); @@ -44,7 +49,9 @@ impl Users { let path = "/users".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. @@ -76,7 +83,9 @@ impl Users { let path = "/users".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the @@ -103,7 +112,9 @@ impl Users { let path = "/users/argon2".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the @@ -130,7 +141,9 @@ impl Users { let path = "/users/bcrypt".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get identities for all users. @@ -142,7 +155,10 @@ impl Users { ) -> 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::>())); + 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)); @@ -155,7 +171,9 @@ impl Users { let path = "/users/identities".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete an identity by its unique ID. @@ -167,9 +185,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/users/identities/{identityId}".to_string().replace("{identityId}", &identity_id.into().to_string()); + let path = "/users/identities/{identityId}" + .to_string() + .replace("{identityId}", &identity_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the @@ -196,7 +218,9 @@ impl Users { let path = "/users/md5".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the @@ -223,7 +247,9 @@ impl Users { let path = "/users/phpass".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the @@ -261,7 +287,9 @@ impl Users { let path = "/users/scrypt".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the [Scrypt @@ -285,8 +313,14 @@ impl Users { params.insert("email".to_string(), json!(email.into())); params.insert("password".to_string(), json!(password.into())); params.insert("passwordSalt".to_string(), json!(password_salt.into())); - params.insert("passwordSaltSeparator".to_string(), json!(password_salt_separator.into())); - params.insert("passwordSignerKey".to_string(), json!(password_signer_key.into())); + params.insert( + "passwordSaltSeparator".to_string(), + json!(password_salt_separator.into()), + ); + params.insert( + "passwordSignerKey".to_string(), + json!(password_signer_key.into()), + ); if let Some(value) = name { params.insert("name".to_string(), json!(value)); } @@ -296,7 +330,9 @@ impl Users { let path = "/users/scrypt-modified".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Create a new user. Password provided must be hashed with the @@ -327,7 +363,9 @@ impl Users { let path = "/users/sha".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a user by its unique ID. @@ -339,9 +377,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Delete a user by its unique ID, thereby releasing it's ID. Since ID is @@ -350,17 +392,18 @@ impl Users { /// ID reserved, use the /// [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) /// endpoint instead. - pub async fn delete( - &self, - user_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, user_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/users/{userId}".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the user email by its unique ID. @@ -375,9 +418,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/email".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/email" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Enable or disable whether a user can impersonate other users. When @@ -396,9 +443,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/impersonator".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/impersonator" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Use this endpoint to create a JSON Web Token for user by its unique ID. You @@ -421,13 +472,17 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/jwts".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/jwts" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update the user labels by its unique ID. - /// + /// /// Labels can be used to grant access to resources. While teams are a way for /// user's to share access to a resource, labels can be defined by the /// developer to grant access without an invitation. See the [Permissions @@ -438,14 +493,24 @@ impl Users { labels: impl IntoIterator>, ) -> crate::error::Result { let mut params = HashMap::new(); - params.insert("labels".to_string(), json!(labels.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "labels".to_string(), + json!(labels + .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 = "/users/{userId}/labels".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/labels" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Get the user activity logs list by its unique ID. @@ -457,7 +522,10 @@ impl Users { ) -> 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::>())); + 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)); @@ -465,9 +533,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/logs".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/logs" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get the user membership list by its unique ID. @@ -480,7 +552,10 @@ impl Users { ) -> 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::>())); + 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)); @@ -491,9 +566,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/memberships".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/memberships" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Enable or disable MFA on a user account. @@ -508,9 +587,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/mfa" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete an authenticator app. @@ -523,9 +606,14 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa/authenticators/{type}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{type}", &r#type.to_string()); + let path = "/users/{userId}/mfa/authenticators/{type}" + .to_string() + .replace("{userId}", &user_id.into().to_string()) + .replace("{type}", &r#type.to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Get a custom MFA challenge for a user, including the code to be delivered @@ -539,9 +627,14 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa/challenges/{challengeId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{challengeId}", &challenge_id.into().to_string()); + let path = "/users/{userId}/mfa/challenges/{challengeId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()) + .replace("{challengeId}", &challenge_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// List the factors available on the account to be used as a MFA challange. @@ -553,9 +646,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa/factors".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/mfa/factors" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Get recovery codes that can be used as backup for MFA flow by User ID. @@ -570,9 +667,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa/recovery-codes".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/mfa/recovery-codes" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Regenerate recovery codes that can be used as backup for MFA flow by User @@ -588,9 +689,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa/recovery-codes".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/mfa/recovery-codes" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Generate recovery codes used as backup for MFA flow for User ID. Recovery @@ -606,9 +711,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/mfa/recovery-codes".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/mfa/recovery-codes" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the user name by its unique ID. @@ -623,9 +732,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/name".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/name" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the user password by its unique ID. @@ -640,9 +753,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/password".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/password" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the user phone by its unique ID. @@ -657,9 +774,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/phone".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/phone" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get the user preferences by its unique ID. @@ -671,9 +792,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/prefs".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/prefs" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update the user preferences by its unique ID. The object you pass is stored @@ -690,9 +815,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/prefs".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/prefs" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Get the user sessions list by its unique ID. @@ -708,13 +837,17 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/sessions".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/sessions" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Creates a session for a user. Returns an immediately usable session object. - /// + /// /// If you want to generate a token for a custom authentication flow, use the /// [POST /// /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) @@ -728,23 +861,28 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/sessions".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/sessions" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Delete all user's sessions by using the user's unique ID. - pub async fn delete_sessions( - &self, - user_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete_sessions(&self, user_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/users/{userId}/sessions".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/sessions" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Delete a user sessions by its unique ID. @@ -757,9 +895,14 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/users/{userId}/sessions/{sessionId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{sessionId}", &session_id.into().to_string()); + let path = "/users/{userId}/sessions/{sessionId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()) + .replace("{sessionId}", &session_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the user status by its unique ID. Use this endpoint as an @@ -775,9 +918,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/status".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/status" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// List the messaging targets that are associated with a user. @@ -789,7 +936,10 @@ impl Users { ) -> 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::>())); + 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)); @@ -797,9 +947,13 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/targets".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/targets" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a messaging target. @@ -826,9 +980,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/targets".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/targets" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a user's push notification target by ID. @@ -841,9 +999,14 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/targets/{targetId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{targetId}", &target_id.into().to_string()); + let path = "/users/{userId}/targets/{targetId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()) + .replace("{targetId}", &target_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a messaging target. @@ -869,9 +1032,14 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/targets/{targetId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{targetId}", &target_id.into().to_string()); + let path = "/users/{userId}/targets/{targetId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()) + .replace("{targetId}", &target_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Delete a messaging target. @@ -884,9 +1052,14 @@ impl Users { let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/users/{userId}/targets/{targetId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{targetId}", &target_id.into().to_string()); + let path = "/users/{userId}/targets/{targetId}" + .to_string() + .replace("{userId}", &user_id.into().to_string()) + .replace("{targetId}", &target_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Returns a token with a secret key for creating a session. Use the user ID @@ -910,9 +1083,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/tokens".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/tokens" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Update the user email verification status by its unique ID. @@ -927,9 +1104,13 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/verification".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/verification" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } /// Update the user phone verification status by its unique ID. @@ -944,11 +1125,14 @@ impl Users { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/users/{userId}/verification/phone".to_string().replace("{userId}", &user_id.into().to_string()); + let path = "/users/{userId}/verification/phone" + .to_string() + .replace("{userId}", &user_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Users { diff --git a/src/services/vectors_db.rs b/src/services/vectors_db.rs new file mode 100644 index 0000000..2cbe964 --- /dev/null +++ b/src/services/vectors_db.rs @@ -0,0 +1,1092 @@ +//! VectorsDB service for Appwrite SDK + +use crate::client::Client; + +use reqwest::Method; +use serde_json::json; +use std::collections::HashMap; + +#[derive(Debug, Clone)] +pub struct VectorsDB { + client: Client, +} + +impl VectorsDB { + pub fn new(client: &Client) -> Self { + Self { + client: client.clone(), + } + } + + pub fn client(&self) -> &Client { + &self.client + } + + /// Get a list of all databases from the current Appwrite project. You can use + /// the search parameter to filter your results. + pub async fn list( + &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 = "/vectorsdb".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new Database. + pub async fn create( + &self, + database_id: impl Into, + name: impl Into, + enabled: Option, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("databaseId".to_string(), json!(database_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) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".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 = "/vectorsdb".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the dedicated database specifications available on the current plan. + /// Each specification reports its resource limits, pricing, and whether it is + /// enabled for the organization. + pub async fn list_specifications( + &self, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/specifications".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// List transactions across all databases. + pub async fn list_transactions( + &self, + 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 path = "/vectorsdb/transactions".to_string(); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new transaction. + pub async fn create_transaction( + &self, + ttl: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + 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 = "/vectorsdb/transactions".to_string(); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a transaction by its unique ID. + pub async fn get_transaction( + &self, + transaction_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a transaction, to either commit or roll back its operations. + pub async fn update_transaction( + &self, + transaction_id: impl Into, + commit: Option, + rollback: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = commit { + params.insert("commit".to_string(), json!(value)); + } + if let Some(value) = rollback { + params.insert("rollback".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 = "/vectorsdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a transaction by its unique ID. + pub async fn delete_transaction( + &self, + transaction_id: impl Into, + ) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/transactions/{transactionId}" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Create multiple operations in a single transaction. + pub async fn create_operations( + &self, + transaction_id: impl Into, + operations: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = operations { + params.insert("operations".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 = "/vectorsdb/transactions/{transactionId}/operations" + .to_string() + .replace("{transactionId}", &transaction_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a database by its unique ID. This endpoint response returns a JSON + /// object with the database metadata. + pub async fn get( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a database by its unique ID. + pub async fn update( + &self, + database_id: impl Into, + name: impl Into, + enabled: Option, + specification: Option<&str>, + replicas: Option, + sync_mode: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = enabled { + params.insert("enabled".to_string(), json!(value)); + } + if let Some(value) = specification { + params.insert("specification".to_string(), json!(value)); + } + if let Some(value) = replicas { + params.insert("replicas".to_string(), json!(value)); + } + if let Some(value) = sync_mode { + params.insert("syncMode".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 = "/vectorsdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a database by its unique ID. Only API keys with with databases.write + /// scope can delete a database. + pub async fn delete(&self, database_id: impl Into) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a list of all collections that belong to the provided databaseId. You + /// can use the search parameter to filter your results. + pub async fn list_collections( + &self, + database_id: impl Into, + 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 = "/vectorsdb/{databaseId}/collections" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new Collection. Before using this route, you should create a new + /// database resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + #[allow(clippy::too_many_arguments)] + pub async fn create_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + name: impl Into, + dimension: i64, + permissions: Option>, + document_security: Option, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("collectionId".to_string(), json!(collection_id.into())); + params.insert("name".to_string(), json!(name.into())); + params.insert("dimension".to_string(), json!(dimension)); + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = document_security { + params.insert("documentSecurity".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 = "/vectorsdb/{databaseId}/collections" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a collection by its unique ID. This endpoint response returns a JSON + /// object with the collection metadata. + pub async fn get_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a collection by its unique ID. + #[allow(clippy::too_many_arguments)] + pub async fn update_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + name: impl Into, + dimension: Option, + permissions: Option>, + document_security: Option, + enabled: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("name".to_string(), json!(name.into())); + if let Some(value) = dimension { + params.insert("dimension".to_string(), json!(value)); + } + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = document_security { + params.insert("documentSecurity".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 = "/vectorsdb/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a collection by its unique ID. Only users with write permissions + /// have access to delete this resource. + pub async fn delete_collection( + &self, + database_id: impl Into, + collection_id: impl Into, + ) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a list of all the user's documents in a given collection. You can use + /// the query params to filter your results. + pub async fn list_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + queries: Option>, + transaction_id: Option<&str>, + total: Option, + ttl: 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) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + if let Some(value) = total { + params.insert("total".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("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create a new Document. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn create_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + data: serde_json::Value, + permissions: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("documentId".to_string(), json!(document_id.into())); + params.insert("data".to_string(), json!(data)); + if let Some(value) = permissions { + params.insert( + "permissions".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Create new Documents. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn create_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + documents: Vec, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("documents".to_string(), json!(documents)); + let mut api_headers = 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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Create or update Documents. Before using this route, you should create a + /// new collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn upsert_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + documents: Vec, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("documents".to_string(), json!(documents)); + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Update all documents that match your queries, if no queries are submitted + /// then all documents are updated. You can pass only specific fields to be + /// updated. + pub async fn update_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + data: Option, + queries: Option>, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = data { + params.insert("data".to_string(), json!(value)); + } + if let Some(value) = queries { + params.insert( + "queries".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Bulk delete documents using queries, if no queries are passed then all + /// documents are deleted. + pub async fn delete_documents( + &self, + database_id: impl Into, + collection_id: impl Into, + queries: Option>, + transaction_id: 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) = transaction_id { + params.insert("transactionId".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a list of all the user's documents in a given collection using a POST + /// request. This behaves identically to the list documents endpoint but + /// accepts the queries in the request body, allowing much larger `queries` + /// arrays than can fit in a URL query string. + pub async fn create_query( + &self, + database_id: impl Into, + collection_id: impl Into, + queries: Option>, + transaction_id: Option<&str>, + total: Option, + ttl: 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) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + if let Some(value) = total { + params.insert("total".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/query" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get a document by its unique ID. This endpoint response returns a JSON + /// object with the document data. + pub async fn get_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + queries: Option>, + transaction_id: 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) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Create or update a Document. Before using this route, you should create a + /// new collection resource using either a [server + /// integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) + /// API or directly from your database console. + pub async fn upsert_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + data: Option, + permissions: Option>, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = data { + params.insert("data".to_string(), json!(value)); + } + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await + } + + /// Update a document by its unique ID. Using the patch method you can pass + /// only specific fields that will get updated. + pub async fn update_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + data: Option, + permissions: Option>, + transaction_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = data { + params.insert("data".to_string(), json!(value)); + } + if let Some(value) = permissions { + params.insert( + "permissions".to_string(), + json!(value.into_iter().map(|s| s.into()).collect::>()), + ); + } + if let Some(value) = transaction_id { + params.insert("transactionId".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete a document by its unique ID. + pub async fn delete_document( + &self, + database_id: impl Into, + collection_id: impl Into, + document_id: impl Into, + transaction_id: Option<&str>, + ) -> crate::error::Result<()> { + let mut params = HashMap::new(); + if let Some(value) = transaction_id { + params.insert("transactionId".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{documentId}", &document_id.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// List indexes in the collection. + pub async fn list_indexes( + &self, + database_id: impl Into, + collection_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 path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Creates an index on the attributes listed. Your index should include all + /// the attributes you will query in a single request. + /// Attributes can be `key`, `fulltext`, and `unique`. + #[allow(clippy::too_many_arguments)] + pub async fn create_index( + &self, + database_id: impl Into, + collection_id: impl Into, + key: impl Into, + r#type: crate::enums::VectorsDBIndexType, + attributes: impl IntoIterator>, + orders: Option>, + lengths: Option>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + params.insert("key".to_string(), json!(key.into())); + params.insert("type".to_string(), json!(r#type)); + params.insert( + "attributes".to_string(), + json!(attributes + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); + if let Some(value) = orders { + params.insert("orders".to_string(), json!(value)); + } + if let Some(value) = lengths { + params.insert("lengths".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 = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// Get index by ID. + pub async fn get_index( + &self, + database_id: impl Into, + collection_id: impl Into, + key: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Delete an index. + pub async fn delete_index( + &self, + database_id: impl Into, + collection_id: impl Into, + key: impl Into, + ) -> crate::error::Result<()> { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("content-type".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()) + .replace("{collectionId}", &collection_id.into().to_string()) + .replace("{key}", &key.into().to_string()); + + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await + } + + /// Trigger a manual failover for a dedicated database with high availability + /// enabled. Promotes a replica to primary. The failover runs asynchronously; + /// poll the database document for status updates. A database left + /// mid-operation also accepts this call as a repair once nothing is driving + /// the operation it is stuck in. Repairing a failover that did not finish, a + /// `failed` database, a stranded upgrade or migrate, or a stranded compute + /// resize additionally requires `targetReplicaId` to name the member to + /// promote, because the default target may be the member that operation + /// already promoted. + pub async fn create_failover( + &self, + database_id: impl Into, + target_replica_id: Option<&str>, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = target_replica_id { + params.insert("targetReplicaId".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 = "/vectorsdb/{databaseId}/failovers" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await + } + + /// List the lifecycle operations recorded for a dedicated database, newest + /// first. Every provision, update, restore, backup and replication action is + /// recorded here with its outcome, including an attempt that was abandoned + /// because another worker took over the database. + pub async fn list_operations( + &self, + database_id: impl Into, + status: Option<&str>, + limit: Option, + offset: Option, + ) -> crate::error::Result { + let mut params = HashMap::new(); + if let Some(value) = status { + params.insert("status".to_string(), json!(value)); + } + if let Some(value) = limit { + params.insert("limit".to_string(), json!(value)); + } + if let Some(value) = offset { + params.insert("offset".to_string(), json!(value)); + } + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/operations" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get high availability status for a dedicated database. Returns replica + /// statuses, replication lag, and sync mode. + pub async fn get_replicas( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/replicas" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } + + /// Get real-time health and status information for a dedicated database. + /// Returns health status, readiness, uptime, connection info, replica status, + /// and volume information. + pub async fn get_status( + &self, + database_id: impl Into, + ) -> crate::error::Result { + let params = HashMap::new(); + let mut api_headers = HashMap::new(); + api_headers.insert("accept".to_string(), "application/json".to_string()); + + let path = "/vectorsdb/{databaseId}/status" + .to_string() + .replace("{databaseId}", &database_id.into().to_string()); + + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await + } +} + +impl crate::services::Service for VectorsDB { + fn client(&self) -> &Client { + &self.client + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_vectors_db_creation() { + let client = Client::new(); + let service = VectorsDB::new(&client); + assert!(service.client().endpoint().contains("cloud.appwrite.io/v1")); + } +} diff --git a/src/services/webhooks.rs b/src/services/webhooks.rs index dedc7a1..0e3e171 100644 --- a/src/services/webhooks.rs +++ b/src/services/webhooks.rs @@ -14,7 +14,9 @@ pub struct Webhooks { impl Webhooks { pub fn new(client: &Client) -> Self { - Self { client: client.clone() } + Self { + client: client.clone(), + } } pub fn client(&self) -> &Client { @@ -30,7 +32,10 @@ impl Webhooks { ) -> 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::>())); + 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)); @@ -40,7 +45,9 @@ impl Webhooks { let path = "/webhooks".to_string(); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Create a new webhook. Use this endpoint to configure a URL that will @@ -62,7 +69,13 @@ impl Webhooks { params.insert("webhookId".to_string(), json!(webhook_id.into())); params.insert("url".to_string(), json!(url.into())); params.insert("name".to_string(), json!(name.into())); - params.insert("events".to_string(), json!(events.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "events".to_string(), + json!(events + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } @@ -84,7 +97,9 @@ impl Webhooks { let path = "/webhooks".to_string(); - self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::POST, &path, Some(api_headers), Some(params)) + .await } /// Get a webhook by its unique ID. This endpoint returns details about a @@ -97,9 +112,13 @@ impl Webhooks { let mut api_headers = HashMap::new(); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/webhooks/{webhookId}".to_string().replace("{webhookId}", &webhook_id.into().to_string()); + let path = "/webhooks/{webhookId}" + .to_string() + .replace("{webhookId}", &webhook_id.into().to_string()); - self.client.call(Method::GET, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::GET, &path, Some(api_headers), Some(params)) + .await } /// Update a webhook by its unique ID. Use this endpoint to update the URL, @@ -119,7 +138,13 @@ impl Webhooks { let mut params = HashMap::new(); params.insert("name".to_string(), json!(name.into())); params.insert("url".to_string(), json!(url.into())); - params.insert("events".to_string(), json!(events.into_iter().map(|s| s.into()).collect::>())); + params.insert( + "events".to_string(), + json!(events + .into_iter() + .map(|s| s.into()) + .collect::>()), + ); if let Some(value) = enabled { params.insert("enabled".to_string(), json!(value)); } @@ -136,24 +161,29 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/webhooks/{webhookId}".to_string().replace("{webhookId}", &webhook_id.into().to_string()); + let path = "/webhooks/{webhookId}" + .to_string() + .replace("{webhookId}", &webhook_id.into().to_string()); - self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PUT, &path, Some(api_headers), Some(params)) + .await } /// Delete a webhook by its unique ID. Once deleted, the webhook will no longer /// receive project events. - pub async fn delete( - &self, - webhook_id: impl Into, - ) -> crate::error::Result<()> { + pub async fn delete(&self, webhook_id: impl Into) -> crate::error::Result<()> { let params = HashMap::new(); let mut api_headers = HashMap::new(); api_headers.insert("content-type".to_string(), "application/json".to_string()); - let path = "/webhooks/{webhookId}".to_string().replace("{webhookId}", &webhook_id.into().to_string()); + let path = "/webhooks/{webhookId}" + .to_string() + .replace("{webhookId}", &webhook_id.into().to_string()); - self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::DELETE, &path, Some(api_headers), Some(params)) + .await } /// Update the webhook signing key. This endpoint can be used to regenerate the @@ -172,11 +202,14 @@ impl Webhooks { api_headers.insert("content-type".to_string(), "application/json".to_string()); api_headers.insert("accept".to_string(), "application/json".to_string()); - let path = "/webhooks/{webhookId}/secret".to_string().replace("{webhookId}", &webhook_id.into().to_string()); + let path = "/webhooks/{webhookId}/secret" + .to_string() + .replace("{webhookId}", &webhook_id.into().to_string()); - self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await + self.client + .call(Method::PATCH, &path, Some(api_headers), Some(params)) + .await } - } impl crate::services::Service for Webhooks {