use crate::client::EdgeQuakeClient;
use crate::error::Result;
use crate::types::graph::*;
pub struct RelationshipsResource<'a> {
pub(crate) client: &'a EdgeQuakeClient,
}
impl<'a> RelationshipsResource<'a> {
pub async fn list(&self) -> Result<RelationshipListResponse> {
self.client.get("/api/v1/graph/relationships").await
}
pub async fn create(&self, req: &CreateRelationshipRequest) -> Result<Relationship> {
self.client
.post("/api/v1/graph/relationships", Some(req))
.await
}
pub async fn delete(&self, id: &str) -> Result<()> {
self.client
.delete_no_content(&format!("/api/v1/graph/relationships/{id}"))
.await
}
pub async fn get(&self, id: &str) -> Result<Relationship> {
self.client
.get(&format!("/api/v1/graph/relationships/{id}"))
.await
}
pub async fn update(
&self,
id: &str,
body: &serde_json::Value,
) -> Result<serde_json::Value> {
self.client
.put(
&format!("/api/v1/graph/relationships/{id}"),
Some(body),
)
.await
}
}