-
Notifications
You must be signed in to change notification settings - Fork 102
Add support for export API #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis PR adds client-side support for the Meilisearch Changes
Sequence DiagramsequenceDiagram
participant User
participant Client
participant Meilisearch
User->>User: Build ExportPayload<br/>(url, api_key, indexes, etc.)
User->>Client: create_export(payload)
Client->>Meilisearch: POST /export<br/>(with configured payload)
Meilisearch-->>Client: 202 Accepted<br/>TaskInfo
Client-->>User: TaskInfo<br/>(task_uid, status, etc.)
Note over User: Task can be tracked<br/>via existing task APIs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/tasks.rs (1)
105-121: Redact api_key in Debug to avoid accidental secret leakage.ExportTaskDetails derives Debug and includes api_key; Debug prints often end up in logs. Recommend redacting in Debug.
Apply this diff:
-#[derive(Debug, Clone, Deserialize)] +#[derive(Clone, Deserialize)] pub struct ExportTaskDetails { pub url: Option<String>, pub api_key: Option<String>, pub payload_size: Option<String>, pub indexes: Option<BTreeMap<String, ExportTaskIndexDetails>>, } + +impl std::fmt::Debug for ExportTaskDetails { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ExportTaskDetails") + .field("url", &self.url) + .field("api_key", &self.api_key.as_ref().map(|_| "****")) + .field("payload_size", &self.payload_size) + .field("indexes", &self.indexes) + .finish() + } +}src/export.rs (2)
131-137: Make with_filter accept Into for ergonomics.Allows passing &str or String directly without json!/into() ceremony.
Apply this diff:
- pub fn with_filter(mut self, filter: Value) -> Self { - self.filter = Some(filter); + pub fn with_filter<T: Into<Value>>(mut self, filter: T) -> Self { + self.filter = Some(filter.into()); self }
199-307: Add a test to assert default fields are omitted from the payload.Verify overrideSettings: false and payloadSize: None don’t serialize.
Example to add under cfg(feature = "reqwest"):
#[tokio::test] async fn test_create_export_omits_defaults() -> Result<(), Error> { let mut server = mockito::Server::new_async().await; let base = server.url(); let _mock = server .mock("POST", "/export") .match_header("authorization", "Bearer masterKey") .match_header("content-type", "application/json") .match_body(Matcher::Json(serde_json::json!({ "url": "https://ms-cloud.example.com", "indexes": { "movies": { "filter": "genres = action" } } }))) .with_status(202) .with_body(r#"{"enqueuedAt":"2024-01-01T00:00:00Z","status":"enqueued","taskUid":3,"type":"export"}"#) .create_async() .await; let client = Client::new(base, Some("masterKey")).unwrap(); let payload = ExportPayload::new("https://ms-cloud.example.com") .with_index("movies", ExportIndexOptions::new().with_filter("genres = action")); let _ = client.create_export(payload).await?; Ok(()) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.code-samples.meilisearch.yaml(1 hunks)src/export.rs(1 hunks)src/lib.rs(1 hunks)src/tasks.rs(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: integration-tests
🔇 Additional comments (3)
.code-samples.meilisearch.yaml (1)
1348-1357: Sample looks correct and aligned with the new API.The snippet correctly demonstrates create_export with URL, API key, payload size, and index-wide override settings. No changes needed.
src/lib.rs (1)
241-243: Public export module exposure LGTM.Clean addition; docs will link through.
src/tasks.rs (1)
48-50: New TaskType::Export variant fits the task model.Enum tagging remains camelCase; “Export” → "export" matches server payloads.
Pull Request
Related issue
Fixes #695
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit