use async_trait::async_trait;
use toolkit_canonical_errors::CanonicalError;
use toolkit_security::SecurityContext;
use crate::models::{
DeleteOutcome, EdgeKey, GraphRevision, GtsTypeId, IngestOutcome, IngestRequest,
NeighborhoodRequest, NodeKey, NodeRow, NodeView, Page, SearchRequest, SearchResponse,
TraversalResponse, TraverseRequest, TypeQuery, TypeRecord, TypeRegistration,
};
#[async_trait]
pub trait GraphStorageClientV1: Send + Sync {
async fn register_types(
&self,
ctx: &SecurityContext,
batch: Vec<TypeRegistration>,
) -> Result<Vec<TypeRecord>, CanonicalError>;
async fn get_type(
&self,
ctx: &SecurityContext,
type_id: &GtsTypeId,
) -> Result<TypeRecord, CanonicalError>;
async fn list_types(
&self,
ctx: &SecurityContext,
query: TypeQuery,
) -> Result<Page<TypeRecord>, CanonicalError>;
async fn ingest(
&self,
ctx: &SecurityContext,
request: IngestRequest,
) -> Result<IngestOutcome, CanonicalError>;
async fn delete_node(
&self,
ctx: &SecurityContext,
node_key: &NodeKey,
) -> Result<DeleteOutcome, CanonicalError>;
async fn delete_edge(
&self,
ctx: &SecurityContext,
edge_key: &EdgeKey,
) -> Result<DeleteOutcome, CanonicalError>;
async fn get_node(
&self,
ctx: &SecurityContext,
node_key: &NodeKey,
adjacency_limit: Option<u32>,
) -> Result<NodeView, CanonicalError>;
async fn project_nodes(
&self,
ctx: &SecurityContext,
type_patterns: &[String],
query: toolkit_odata::ODataQuery,
) -> Result<toolkit_odata::Page<NodeRow>, CanonicalError>;
async fn search(
&self,
ctx: &SecurityContext,
request: SearchRequest,
) -> Result<SearchResponse, CanonicalError>;
async fn traverse(
&self,
ctx: &SecurityContext,
request: TraverseRequest,
) -> Result<TraversalResponse, CanonicalError>;
async fn neighborhood(
&self,
ctx: &SecurityContext,
request: NeighborhoodRequest,
) -> Result<TraversalResponse, CanonicalError>;
async fn revision(&self, ctx: &SecurityContext) -> Result<GraphRevision, CanonicalError>;
}