pub struct BrainHttpClient { /* private fields */ }Expand description
An async HTTP client for the Brain edge.
Implementations§
Source§impl BrainHttpClient
impl BrainHttpClient
Sourcepub fn new(api_key: impl Into<String>, base_url: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>, base_url: impl Into<String>) -> Self
Authenticate as api_key against base_url. Uses the
DEFAULT_TIMEOUT request timeout and the default HttpRetryPolicy.
Key first, URL second — matching the Python and TypeScript clients,
which both take the key as the required argument and the URL as the
optional one. Both parameters are impl Into<String>, so a swapped call
compiles cleanly and sends the base URL as the bearer token; keeping the
three SDKs in one order is the only thing that makes that mistake hard.
Self::localhost covers the common case in one argument.
Sourcepub fn localhost(api_key: impl Into<String>) -> Self
pub fn localhost(api_key: impl Into<String>) -> Self
Build a client against DEFAULT_BASE_URL.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Override the per-request timeout (default DEFAULT_TIMEOUT). A timeout
surfaces as a transport BrainHttpError, not a panic.
Sourcepub fn with_retry_policy(self, policy: HttpRetryPolicy) -> Self
pub fn with_retry_policy(self, policy: HttpRetryPolicy) -> Self
Override the retry policy applied to idempotent verbs (encode,
whoami, capabilities). Pass HttpRetryPolicy::none to disable.
Sourcepub async fn encode(
&self,
input: &EncodeInput,
) -> Result<EncodeResult, BrainHttpError>
pub async fn encode( &self, input: &EncodeInput, ) -> Result<EncodeResult, BrainHttpError>
Store a memory. Idempotent (stable server-side request id) — retried.
Sourcepub async fn recall(
&self,
input: &RecallInput,
) -> Result<RecallResult, BrainHttpError>
pub async fn recall( &self, input: &RecallInput, ) -> Result<RecallResult, BrainHttpError>
Recall memories for a cue.
Sourcepub async fn forget(
&self,
input: &ForgetInput,
) -> Result<ForgetResult, BrainHttpError>
pub async fn forget( &self, input: &ForgetInput, ) -> Result<ForgetResult, BrainHttpError>
Forget a memory.
Sourcepub async fn link(
&self,
input: &LinkInput,
) -> Result<LinkResult, BrainHttpError>
pub async fn link( &self, input: &LinkInput, ) -> Result<LinkResult, BrainHttpError>
Create/overwrite a directed edge between two memories.
Sourcepub async fn unlink(
&self,
input: &UnlinkInput,
) -> Result<UnlinkResult, BrainHttpError>
pub async fn unlink( &self, input: &UnlinkInput, ) -> Result<UnlinkResult, BrainHttpError>
Remove a directed edge (idempotent).
Sourcepub async fn plan(
&self,
input: &PlanInput,
) -> Result<PlanResult, BrainHttpError>
pub async fn plan( &self, input: &PlanInput, ) -> Result<PlanResult, BrainHttpError>
Plan a path from a start state to a goal state.
Sourcepub async fn reason(
&self,
input: &ReasonInput,
) -> Result<ReasonResult, BrainHttpError>
pub async fn reason( &self, input: &ReasonInput, ) -> Result<ReasonResult, BrainHttpError>
Infer over the graph from an observation.
Sourcepub async fn whoami(&self) -> Result<Whoami, BrainHttpError>
pub async fn whoami(&self) -> Result<Whoami, BrainHttpError>
The identity Brain resolves from the credential. Idempotent GET — retried.
Sourcepub async fn capabilities(&self) -> Result<Capabilities, BrainHttpError>
pub async fn capabilities(&self) -> Result<Capabilities, BrainHttpError>
What the connected shard supports. Idempotent GET — retried.
Sourcepub async fn memory_list(
&self,
query: &MemoryListQuery,
) -> Result<MemoryListPage, BrainHttpError>
pub async fn memory_list( &self, query: &MemoryListQuery, ) -> Result<MemoryListPage, BrainHttpError>
A page of the space’s memories. This is not a recall: no cue, no ranking, just the timeline in a stable order plus a cursor.
Sourcepub async fn memory_inspect(
&self,
memory_id: &str,
) -> Result<MemoryInspect, BrainHttpError>
pub async fn memory_inspect( &self, memory_id: &str, ) -> Result<MemoryInspect, BrainHttpError>
Everything the encode pipeline produced for one memory: the vector, the persisted row, the extracted graph.
Sourcepub async fn list_entities(
&self,
query: &ListEntitiesQuery,
) -> Result<ListEntitiesResult, BrainHttpError>
pub async fn list_entities( &self, query: &ListEntitiesQuery, ) -> Result<ListEntitiesResult, BrainHttpError>
Entities in the typed graph, filtered by the query.
Sourcepub async fn get_entity(
&self,
entity_id: &str,
) -> Result<EntityDetail, BrainHttpError>
pub async fn get_entity( &self, entity_id: &str, ) -> Result<EntityDetail, BrainHttpError>
One entity by id.
Sourcepub async fn list_relations(
&self,
entity_id: &str,
query: &ListRelationsQuery,
) -> Result<ListRelationsResult, BrainHttpError>
pub async fn list_relations( &self, entity_id: &str, query: &ListRelationsQuery, ) -> Result<ListRelationsResult, BrainHttpError>
The relations incident to one entity.
Sourcepub async fn graph_fetch(
&self,
query: &GraphFetchQuery,
) -> Result<GraphPage, BrainHttpError>
pub async fn graph_fetch( &self, query: &GraphFetchQuery, ) -> Result<GraphPage, BrainHttpError>
One page of the space’s typed graph, as a node/edge set.
Sourcepub async fn get_relation(
&self,
relation_id: &str,
query: &GetRelationQuery,
) -> Result<RelationDetail, BrainHttpError>
pub async fn get_relation( &self, relation_id: &str, query: &GetRelationQuery, ) -> Result<RelationDetail, BrainHttpError>
One relation by id.
Sourcepub async fn list_statements(
&self,
query: &ListStatementsQuery,
) -> Result<ListStatementsResult, BrainHttpError>
pub async fn list_statements( &self, query: &ListStatementsQuery, ) -> Result<ListStatementsResult, BrainHttpError>
Statements in the typed graph, filtered by the query.
Sourcepub async fn get_statement(
&self,
statement_id: &str,
query: &GetStatementQuery,
) -> Result<StatementDetail, BrainHttpError>
pub async fn get_statement( &self, statement_id: &str, query: &GetStatementQuery, ) -> Result<StatementDetail, BrainHttpError>
One statement by id.
Sourcepub async fn get_schema(
&self,
query: &SchemaGetQuery,
) -> Result<Schema, BrainHttpError>
pub async fn get_schema( &self, query: &SchemaGetQuery, ) -> Result<Schema, BrainHttpError>
The active schema document for a namespace, or a specific version of it.
Sourcepub async fn validate_schema(
&self,
input: &SchemaValidateInput,
) -> Result<SchemaValidateResult, BrainHttpError>
pub async fn validate_schema( &self, input: &SchemaValidateInput, ) -> Result<SchemaValidateResult, BrainHttpError>
Check a schema document and report what an upload would do. A dry run that changes nothing, so it is idempotent and retried.
Sourcepub async fn upload_schema(
&self,
input: &SchemaUploadInput,
) -> Result<SchemaUploadResult, BrainHttpError>
pub async fn upload_schema( &self, input: &SchemaUploadInput, ) -> Result<SchemaUploadResult, BrainHttpError>
Upload a schema document as the namespace’s next version.
Sourcepub async fn replace_schema(
&self,
input: &SchemaReplaceInput,
) -> Result<SchemaReplaceResult, BrainHttpError>
pub async fn replace_schema( &self, input: &SchemaReplaceInput, ) -> Result<SchemaReplaceResult, BrainHttpError>
Replace the namespace’s schema, dropping every declared row first. Irreversible, and never retried: a second attempt would drop what the first one just wrote.
Sourcepub async fn create_entity(
&self,
input: &CreateEntityInput,
) -> Result<CreateEntityResult, BrainHttpError>
pub async fn create_entity( &self, input: &CreateEntityInput, ) -> Result<CreateEntityResult, BrainHttpError>
Create an entity in the typed graph.
Sourcepub async fn resolve_entity(
&self,
input: &ResolveEntityInput,
) -> Result<ResolveEntityResult, BrainHttpError>
pub async fn resolve_entity( &self, input: &ResolveEntityInput, ) -> Result<ResolveEntityResult, BrainHttpError>
Resolve a candidate name against the typed graph, optionally creating the entity when nothing matches.
Sourcepub async fn traverse_relations(
&self,
entity_id: &str,
input: &TraverseInput,
) -> Result<TraverseResult, BrainHttpError>
pub async fn traverse_relations( &self, entity_id: &str, input: &TraverseInput, ) -> Result<TraverseResult, BrainHttpError>
Walk the relation graph outward from one entity.