fathom¶
Package fathom provides a Go client for the Fathom policy engine REST API.
Index¶
- type AssertFactRequest
- type AssertFactResponse
- type Client
- func NewClient(baseURL string, opts ...ClientOption) *Client
- func (c *Client) AssertFact(ctx context.Context, req *AssertFactRequest) (*AssertFactResponse, error)
- func (c *Client) Evaluate(ctx context.Context, req *EvaluateRequest) (*EvaluateResponse, error)
- func (c *Client) Query(ctx context.Context, req *QueryRequest) (*QueryResponse, error)
- func (c *Client) Retract(ctx context.Context, req *RetractRequest) (*RetractResponse, error)
- type ClientOption
- func WithBearerToken(tok string) ClientOption
- func WithHTTPClient(hc *http.Client) ClientOption
- type EvaluateRequest
- type EvaluateResponse
- type FactInput
- type QueryRequest
- type QueryResponse
- type RetractRequest
- type RetractResponse
type AssertFactRequest¶
AssertFactRequest is the payload for POST /v1/facts.
type AssertFactRequest struct {
SessionID string `json:"session_id"`
Template string `json:"template"`
Data map[string]any `json:"data"`
}
type AssertFactResponse¶
AssertFactResponse is the response from POST /v1/facts.
type Client¶
Client communicates with the Fathom REST API.
func NewClient¶
NewClient creates a new Fathom client pointing at the given base URL. Example:
func (*Client) AssertFact¶
func (c *Client) AssertFact(ctx context.Context, req *AssertFactRequest) (*AssertFactResponse, error)
AssertFact asserts a single fact into the session's working memory.
func (*Client) Evaluate¶
Evaluate sends facts to the engine and returns the policy decision.
func (*Client) Query¶
Query retrieves facts from the session's working memory.
func (*Client) Retract¶
Retract removes facts matching the request's template + optional filter from the session's working memory and returns the number of retractions.
type ClientOption¶
ClientOption mutates a Client during construction.
func WithBearerToken¶
WithBearerToken configures the client to send "Authorization: Bearer \<tok>" on every request.
func WithHTTPClient¶
WithHTTPClient overrides the underlying *http.Client (useful for tests or custom transports).
type EvaluateRequest¶
EvaluateRequest is the payload for POST /v1/evaluate.
type EvaluateRequest struct {
Facts []FactInput `json:"facts"`
Ruleset string `json:"ruleset"`
SessionID string `json:"session_id,omitempty"`
}
type EvaluateResponse¶
EvaluateResponse is the response from POST /v1/evaluate.
type EvaluateResponse struct {
Decision string `json:"decision"`
Reason string `json:"reason"`
RuleTrace []string `json:"rule_trace"`
ModuleTrace []string `json:"module_trace"`
DurationUS int64 `json:"duration_us"`
AttestationToken string `json:"attestation_token,omitempty"`
}
type FactInput¶
FactInput is a single fact assertion used inside EvaluateRequest.
type QueryRequest¶
QueryRequest is the payload for POST /v1/query.
type QueryRequest struct {
SessionID string `json:"session_id"`
Template string `json:"template"`
Filter map[string]any `json:"filter,omitempty"`
}
type QueryResponse¶
QueryResponse is the response from POST /v1/query.
type RetractRequest¶
RetractRequest is the payload for DELETE /v1/facts.
type RetractRequest struct {
SessionID string `json:"session_id"`
Template string `json:"template"`
Filter map[string]any `json:"filter,omitempty"`
}
type RetractResponse¶
RetractResponse is the response from DELETE /v1/facts.
Generated by gomarkdoc