Skip to content

feat: Rust SDK update for version 0.2.0#11

Merged
ChiragAgg5k merged 2 commits intomainfrom
dev
Mar 28, 2026
Merged

feat: Rust SDK update for version 0.2.0#11
ChiragAgg5k merged 2 commits intomainfrom
dev

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

@ChiragAgg5k ChiragAgg5k commented Mar 28, 2026

This PR contains updates to the Rust SDK for version 0.2.0.

Summary by CodeRabbit

Release Notes - Version 0.2.0

  • New Features

    • Added Project service for managing environment variables (list, create, read, update, delete operations)
    • Introduced support for Documentsdb and Vectorsdb services
  • Updates

    • Updated Appwrite server compatibility to 1.9.x
    • Added project-level permission scopes
    • Enhanced API parameters to accept multiple values
    • Removed deprecated queue monitoring methods
    • Removed release candidate runtime options

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

Walkthrough

This PR bumps the SDK version from 0.1.0 to 0.2.0 across package metadata and documentation. It removes all release-candidate (Rc) build and runtime enum variants, introduces three new database service types (Tablesdb, Documentsdb, Vectorsdb), and renames the IndexType enum to DatabasesIndexType and TablesDBIndexType for clarity. Multiple service methods update parameter types from single values to vectors (permissions, services, scopes, orders). The Health service removes five queue-specific methods, and a new Project service module is added with five environment variable management methods. Model field types change from Vec to Vec<serde_json::Value> for increased flexibility, and the client's file upload logic simplifies by removing conditional URL construction based on upload_id.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: a version bump and SDK update from 0.1.0 to 0.2.0, which is clearly the main objective evident across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChiragAgg5k ChiragAgg5k changed the title feat: Rust SDK update for version 0.1.0 feat: Rust SDK update for version 0.2.0 Mar 28, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR updates the Rust SDK to target Appwrite server version 1.9.x, introducing a new Project service, adding new enum variants, removing RC runtime variants, fixing the single-file upload URL construction, and widening several parameter types from single values to Vec<T> to match the updated API.

Key changes:

  • New Project service with 5 variable management endpoints (list_variables, create_variable, get_variable, update_variable, delete_variable)
  • IndexType renamed to TablesDBIndexType (for TablesDB) and a new DatabasesIndexType added for the Databases service — breaking change for existing consumers
  • Parameter types widened to Vec<T> across Backups, Databases, Functions, TablesDB, and Avatars services
  • Models updated: attributes and columns fields changed from Vec<String> to Vec<serde_json::Value>
  • client.rs fix: Removed incorrect upload_id path-appending for single-file uploads
  • Health service trimmed: 5 endpoints removed that no longer exist in Appwrite 1.9.x
  • One defect: project::update_variable marks key as Option<&str> but all equivalent SDK methods treat it as required

Confidence Score: 4/5

Safe to merge after fixing the required key parameter in project update_variable

One P1 defect: project update_variable accepts key as Option which means callers can omit it and send an incomplete PUT body that the Appwrite API will reject. All other changes are consistent and correctly aligned.

src/services/project.rs — update_variable signature needs key to be a required parameter

Important Files Changed

Filename Overview
src/services/project.rs New Project service; update_variable incorrectly marks key as optional
src/client.rs Removes incorrect upload_id path-appending for single-file uploads
src/enums/mod.rs IndexType replaced by DatabasesIndexType and TablesDBIndexType
src/services/health.rs 5 deprecated queue endpoints removed
src/services/backups.rs services param widened to Vec
src/models/attribute_list.rs attributes field changed from Vec to Vec<serde_json::Value>

Reviews (1): Last reviewed commit: "chore: update Rust SDK to 0.2.0" | Re-trigger Greptile

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/services/databases.rs (1)

1740-1752: ⚠️ Potential issue | 🟡 Minor

Update the create_index docs to include spatial.

DatabasesIndexType now exposes Spatial, but the doc comment above create_index still advertises only key, fulltext, and unique.

📝 Suggested doc fix
-    /// Attributes can be `key`, `fulltext`, and `unique`.
+    /// Attributes can be `key`, `fulltext`, `unique`, and `spatial`.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/services/databases.rs` around lines 1740 - 1752, The doc comment for the
create_index method is out of date: update the documentation above pub async fn
create_index to list the new Spatial option by adding `spatial` to the allowed
attribute types (so it reads something like "Attributes can be `key`,
`fulltext`, `unique`, and `spatial`"); ensure the comment references the
DatabasesIndexType enum (crate::enums::DatabasesIndexType) so future enum
additions are obvious.
🧹 Nitpick comments (6)
src/enums/template_reference_type.rs (1)

6-9: Lock the new default (Commit) with regression tests.

Line 6 changes the enum default semantics. That’s fine if intentional, but it’s a subtle SDK behavior change; please add unit tests to pin Default::default() and all as_str() mappings.

Proposed test addition
 impl std::fmt::Display for TemplateReferenceType {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         write!(f, "{}", self.as_str())
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::TemplateReferenceType;
+
+    #[test]
+    fn default_is_commit() {
+        assert_eq!(TemplateReferenceType::default(), TemplateReferenceType::Commit);
+    }
+
+    #[test]
+    fn as_str_mappings_are_stable() {
+        assert_eq!(TemplateReferenceType::Commit.as_str(), "commit");
+        assert_eq!(TemplateReferenceType::Branch.as_str(), "branch");
+        assert_eq!(TemplateReferenceType::Tag.as_str(), "tag");
+    }
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/enums/template_reference_type.rs` around lines 6 - 9, The change makes
Commit the enum default for TemplateReferenceType; add unit tests that pin this
behavior and the string mappings: create tests (e.g.,
test_default_template_reference_type and
test_template_reference_type_as_str_and_serde) that assert Default::default() ==
TemplateReferenceType::Commit, that TemplateReferenceType::Commit.as_str() and
TemplateReferenceType::Branch.as_str() return the expected strings, and that
serde serializes/deserializes Branch as "branch" (and Commit to its expected
value) to prevent regressions in the Default/as_str/serde mappings.
src/client.rs (2)

92-96: Derive the SDK version from Cargo metadata.

Hard-coding 0.2.0 in multiple headers means the next release needs another manual sweep. Read the version once and reuse it here.

♻️ Suggested change
+        let sdk_version = env!("CARGO_PKG_VERSION");
         headers.insert("X-Appwrite-Response-Format", "1.9.0".parse().unwrap());
-        headers.insert("user-agent", format!("AppwriteRustSDK/0.2.0 ({}; {})", std::env::consts::OS, std::env::consts::ARCH).parse().unwrap());
+        headers.insert("user-agent", format!("AppwriteRustSDK/{sdk_version} ({}; {})", 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.2.0".parse().unwrap());
+        headers.insert("x-sdk-version", sdk_version.parse().unwrap());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client.rs` around lines 92 - 96, Replace the hard-coded "0.2.0" with the
crate version from Cargo metadata and reuse it: create a single SDK version
value (e.g., a const or local binding using env!("CARGO_PKG_VERSION")) and use
that variable in the headers.insert calls for "user-agent" and "x-sdk-version"
(the existing headers variable and the headers.insert(...) calls for
"user-agent" and "x-sdk-version" are the exact locations to update).

619-623: Add a regression test for the new single-part upload path.

Callers like src/services/storage.rs:232-243 still pass upload_id, but this branch now always posts to {endpoint}{path}. Appwrite documents POST /storage/buckets/{bucketId}/files for file creation and uses x-appwrite-id for later chunk requests, so this behavior is worth locking down with a request-construction test. (appwrite.io)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client.rs` around lines 619 - 623, Add a regression test that verifies
the single-part upload branch (when file_size <= chunk_size) constructs the HTTP
request to POST to "{endpoint}{path}" and not the chunk upload URL even if an
upload_id is provided; target the code paths around file_size, chunk_size and
the single_file_upload method in client.rs, mocking or intercepting the outgoing
request to assert the request method/URL and that headers (including any
x-appwrite-id if present) and params are set as expected; place the test
alongside existing storage client tests and ensure it covers the case where
callers (e.g., storage service code) pass upload_id but the client still
performs a single-file POST to the base path.
src/services/project.rs (1)

81-104: Avoid sending empty update payloads in update_variable.

When key, value, and secret are all None, this performs a no-op network call and returns a server-side validation error at best. Add a local precondition check and return a clear SDK error.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/services/project.rs` around lines 81 - 104, In update_variable, add a
local precondition that if none of key/value/secret were provided (i.e.,
params.is_empty()) the function returns an immediate SDK error instead of making
the network call; locate the update_variable function and after building params
check params.is_empty() and return an appropriate
Err(crate::error::Result::Err(...) or a suitable crate::error::Error variant
with a clear message like "no fields provided for update") so callers receive a
clear, local validation error rather than a server-side validation failure.
CHANGELOG.md (1)

8-8: Consider adding a “Changed/Breaking” migration note in this release entry.

Since 0.2.0 includes public API surface changes (renamed types/signature shifts), adding a short migration subsection here would make upgrades safer for SDK consumers.

Also applies to: 856-856

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` at line 8, Under the "## [0.2.0] - TBD" changelog entry add a
short "Changed" or "Breaking Changes / Migration" subsection that lists the
public API renames and signature changes and gives one-line migration steps (old
name → new name or old signature → new signature) for each affected symbol;
specifically mention any renamed types or functions and include example mappings
so SDK consumers know how to update their code. Ensure the subsection sits
directly beneath the 0.2.0 header and uses concise bullet points or short lines
for each change.
src/services/backups.rs (1)

39-43: Guard against empty services vectors in public methods.

These signatures now allow vec![], which weakens the previous type-level guarantee (at least one service). Add an early validation branch to fail fast with a clear client-side error before making the HTTP call.

Also applies to: 100-104, 189-193

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/services/backups.rs` around lines 39 - 43, create_archive currently
accepts services: Vec<crate::enums::BackupServices> and allows an empty vector;
add an early validation at the top of create_archive that returns a client-side
Err when services.is_empty() with a clear message (e.g. "at least one backup
service required") before any HTTP calls; apply the same empty-vector guard to
the other public methods in this file that take services:
Vec<crate::enums::BackupServices> so they likewise fail fast and return the same
client error rather than proceeding with an empty services list.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/services/databases.rs`:
- Around line 1740-1752: The doc comment for the create_index method is out of
date: update the documentation above pub async fn create_index to list the new
Spatial option by adding `spatial` to the allowed attribute types (so it reads
something like "Attributes can be `key`, `fulltext`, `unique`, and `spatial`");
ensure the comment references the DatabasesIndexType enum
(crate::enums::DatabasesIndexType) so future enum additions are obvious.

---

Nitpick comments:
In `@CHANGELOG.md`:
- Line 8: Under the "## [0.2.0] - TBD" changelog entry add a short "Changed" or
"Breaking Changes / Migration" subsection that lists the public API renames and
signature changes and gives one-line migration steps (old name → new name or old
signature → new signature) for each affected symbol; specifically mention any
renamed types or functions and include example mappings so SDK consumers know
how to update their code. Ensure the subsection sits directly beneath the 0.2.0
header and uses concise bullet points or short lines for each change.

In `@src/client.rs`:
- Around line 92-96: Replace the hard-coded "0.2.0" with the crate version from
Cargo metadata and reuse it: create a single SDK version value (e.g., a const or
local binding using env!("CARGO_PKG_VERSION")) and use that variable in the
headers.insert calls for "user-agent" and "x-sdk-version" (the existing headers
variable and the headers.insert(...) calls for "user-agent" and "x-sdk-version"
are the exact locations to update).
- Around line 619-623: Add a regression test that verifies the single-part
upload branch (when file_size <= chunk_size) constructs the HTTP request to POST
to "{endpoint}{path}" and not the chunk upload URL even if an upload_id is
provided; target the code paths around file_size, chunk_size and the
single_file_upload method in client.rs, mocking or intercepting the outgoing
request to assert the request method/URL and that headers (including any
x-appwrite-id if present) and params are set as expected; place the test
alongside existing storage client tests and ensure it covers the case where
callers (e.g., storage service code) pass upload_id but the client still
performs a single-file POST to the base path.

In `@src/enums/template_reference_type.rs`:
- Around line 6-9: The change makes Commit the enum default for
TemplateReferenceType; add unit tests that pin this behavior and the string
mappings: create tests (e.g., test_default_template_reference_type and
test_template_reference_type_as_str_and_serde) that assert Default::default() ==
TemplateReferenceType::Commit, that TemplateReferenceType::Commit.as_str() and
TemplateReferenceType::Branch.as_str() return the expected strings, and that
serde serializes/deserializes Branch as "branch" (and Commit to its expected
value) to prevent regressions in the Default/as_str/serde mappings.

In `@src/services/backups.rs`:
- Around line 39-43: create_archive currently accepts services:
Vec<crate::enums::BackupServices> and allows an empty vector; add an early
validation at the top of create_archive that returns a client-side Err when
services.is_empty() with a clear message (e.g. "at least one backup service
required") before any HTTP calls; apply the same empty-vector guard to the other
public methods in this file that take services:
Vec<crate::enums::BackupServices> so they likewise fail fast and return the same
client error rather than proceeding with an empty services list.

In `@src/services/project.rs`:
- Around line 81-104: In update_variable, add a local precondition that if none
of key/value/secret were provided (i.e., params.is_empty()) the function returns
an immediate SDK error instead of making the network call; locate the
update_variable function and after building params check params.is_empty() and
return an appropriate Err(crate::error::Result::Err(...) or a suitable
crate::error::Error variant with a clear message like "no fields provided for
update") so callers receive a clear, local validation error rather than a
server-side validation failure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10c8f776-2fc7-4f76-b0de-cb39a113b1e1

📥 Commits

Reviewing files that changed from the base of the PR and between b2e4af7 and 309bcc1.

📒 Files selected for processing (26)
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • src/client.rs
  • src/enums/backup_services.rs
  • src/enums/build_runtime.rs
  • src/enums/database_type.rs
  • src/enums/databases_index_type.rs
  • src/enums/mod.rs
  • src/enums/runtime.rs
  • src/enums/scopes.rs
  • src/enums/tables_db_index_type.rs
  • src/enums/template_reference_type.rs
  • src/lib.rs
  • src/models/attribute_list.rs
  • src/models/collection.rs
  • src/models/column_list.rs
  • src/models/table.rs
  • src/services/avatars.rs
  • src/services/backups.rs
  • src/services/databases.rs
  • src/services/functions.rs
  • src/services/health.rs
  • src/services/mod.rs
  • src/services/project.rs
  • src/services/tables_db.rs
💤 Files with no reviewable changes (3)
  • src/services/health.rs
  • src/enums/build_runtime.rs
  • src/enums/runtime.rs

@ChiragAgg5k ChiragAgg5k merged commit adea4c4 into main Mar 28, 2026
1 check passed
@ChiragAgg5k ChiragAgg5k deleted the dev branch March 28, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants