Skip to main content

remendo/client/
api.rs

1//! `SashikoApi` trait: the async interface for Sashiko instance access.
2//!
3//! Uses `async_trait` for object safety — required by `RemoteManager`'s
4//! `Arc<dyn SashikoApi>`.
5
6use crate::client::error::ApiError;
7use crate::client::types::{ListParams, ReviewQuery};
8use crate::models::{
9    EmailMessage, MailingList, Paginated, PatchId, Patchset, PatchsetDetail, ServerStats,
10};
11
12/// Read-only access to a single Sashiko instance.
13///
14/// All methods are async and return `Result<T, ApiError>`.
15/// The trait is object-safe (via `async_trait`) to support
16/// `Arc<dyn SashikoApi>` in `RemoteManager`.
17#[async_trait::async_trait]
18pub trait SashikoApi: Send + Sync {
19    /// List tracked mailing lists.
20    async fn lists(&self) -> Result<Vec<MailingList>, ApiError>;
21
22    /// Search/list patchsets with pagination.
23    async fn patchsets(&self, params: &ListParams) -> Result<Paginated<Patchset>, ApiError>;
24
25    /// Search/list messages with pagination.
26    async fn messages(&self, params: &ListParams) -> Result<Paginated<EmailMessage>, ApiError>;
27
28    /// Full patchset detail (patches, reviews, thread, baseline).
29    async fn patch_detail(&self, id: &PatchId) -> Result<PatchsetDetail, ApiError>;
30
31    /// Patchset summary (lighter than `patch_detail`).
32    async fn patchset_summary(&self, id: &PatchId) -> Result<PatchsetDetail, ApiError>;
33
34    /// Single message detail with thread.
35    async fn message_detail(&self, id: &PatchId) -> Result<EmailMessage, ApiError>;
36
37    /// Review detail. One of `id` or `patchset_id` required.
38    async fn review(&self, params: &ReviewQuery) -> Result<serde_json::Value, ApiError>;
39
40    /// Review detail with logs.
41    async fn review_log(&self, params: &ReviewQuery) -> Result<serde_json::Value, ApiError>;
42
43    /// Server status and counts.
44    async fn stats(&self) -> Result<ServerStats, ApiError>;
45
46    /// Timeline data per day, optionally filtered by subsystem.
47    async fn stats_timeline(
48        &self,
49        subsystem_id: Option<i64>,
50    ) -> Result<serde_json::Value, ApiError>;
51
52    /// Review statistics by provider/model/status.
53    async fn stats_reviews(&self) -> Result<serde_json::Value, ApiError>;
54
55    /// Tool usage statistics.
56    async fn stats_tools(&self) -> Result<serde_json::Value, ApiError>;
57
58    /// Clear any cached responses. Default no-op; overridden by `CachingClient`.
59    fn clear_cache(&self) {}
60}