diff options
| author | soryu <soryu@soryu.co> | 2026-02-03 22:01:29 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-03 22:01:37 +0000 |
| commit | cf0a25af1d2834bfe6c5ea892ce5769936e5a673 (patch) | |
| tree | 476ba326ac1752281a441b5c17d2b3be4b23a2a9 /makima/src/daemon/api/chain.rs | |
| parent | 8361916ce67f3d2ba191ebf27cb50e79cb42e39c (diff) | |
| download | soryu-cf0a25af1d2834bfe6c5ea892ce5769936e5a673.tar.gz soryu-cf0a25af1d2834bfe6c5ea892ce5769936e5a673.zip | |
Add makima chain mechanism
Diffstat (limited to 'makima/src/daemon/api/chain.rs')
| -rw-r--r-- | makima/src/daemon/api/chain.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/makima/src/daemon/api/chain.rs b/makima/src/daemon/api/chain.rs new file mode 100644 index 0000000..7f7826f --- /dev/null +++ b/makima/src/daemon/api/chain.rs @@ -0,0 +1,52 @@ +//! Chain API methods. + +use uuid::Uuid; + +use super::client::{ApiClient, ApiError}; +use super::supervisor::JsonValue; +use crate::db::models::CreateChainRequest; + +impl ApiClient { + /// Create a new chain with contracts. + pub async fn create_chain(&self, req: CreateChainRequest) -> Result<JsonValue, ApiError> { + self.post("/api/v1/chains", &req).await + } + + /// List all chains for the authenticated user. + pub async fn list_chains( + &self, + status: Option<&str>, + limit: i32, + ) -> Result<JsonValue, ApiError> { + let mut params = Vec::new(); + if let Some(s) = status { + params.push(format!("status={}", s)); + } + params.push(format!("limit={}", limit)); + let query_string = format!("?{}", params.join("&")); + self.get(&format!("/api/v1/chains{}", query_string)).await + } + + /// Get a chain by ID. + pub async fn get_chain(&self, chain_id: Uuid) -> Result<JsonValue, ApiError> { + self.get(&format!("/api/v1/chains/{}", chain_id)).await + } + + /// Get contracts in a chain. + pub async fn get_chain_contracts(&self, chain_id: Uuid) -> Result<JsonValue, ApiError> { + self.get(&format!("/api/v1/chains/{}/contracts", chain_id)) + .await + } + + /// Get chain DAG structure for visualization. + pub async fn get_chain_graph(&self, chain_id: Uuid) -> Result<JsonValue, ApiError> { + self.get(&format!("/api/v1/chains/{}/graph", chain_id)) + .await + } + + /// Archive a chain. + pub async fn archive_chain(&self, chain_id: Uuid) -> Result<JsonValue, ApiError> { + self.delete_with_response(&format!("/api/v1/chains/{}", chain_id)) + .await + } +} |
