api

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package api provides HTTP client and types for the Nexus admin API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditRecord

type AuditRecord struct {
	RecordID       string    `json:"record_id"`
	RequestID      string    `json:"request_id"`
	Timestamp      time.Time `json:"timestamp"`
	Source         string    `json:"source"`
	ActorType      string    `json:"actor_type"`
	ActorID        string    `json:"actor_id"`
	EffectiveIP    string    `json:"effective_ip"`
	OperationType  string    `json:"operation_type"`
	Endpoint       string    `json:"endpoint"`
	HTTPMethod     string    `json:"http_method"`
	HTTPStatusCode int       `json:"http_status_code"`
	Subject        string    `json:"subject,omitempty"`
	Destination    string    `json:"destination,omitempty"`
	PolicyDecision string    `json:"policy_decision"`
	PolicyReason   string    `json:"policy_reason,omitempty"`
	LatencyMs      float64   `json:"latency_ms"`
}

AuditRecord is a single audit log entry. Matches audit.InteractionRecord from the server.

type AuditResponse

type AuditResponse struct {
	Records       []AuditRecord `json:"records"`
	TotalMatching int           `json:"total_matching"`
	Limit         int           `json:"limit"`
	Offset        int           `json:"offset"`
	HasMore       bool          `json:"has_more"`
}

AuditResponse is the shape of GET /api/audit/log.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an HTTP client for the Nexus admin API.

func NewClient

func NewClient(base, token string) *Client

NewClient creates a new admin API client.

func (*Client) AuditLog

func (c *Client) AuditLog(limit int) (*AuditResponse, error)

AuditLog fetches GET /api/audit/log.

func (*Client) Config

func (c *Client) Config() (*ConfigResponse, error)

Config fetches GET /api/config.

func (*Client) Conflicts

func (c *Client) Conflicts(opts ConflictOpts) (*ConflictsResponse, error)

Conflicts fetches GET /api/conflicts.

func (*Client) Health

func (c *Client) Health() (bool, error)

Health fetches GET /health.

func (*Client) Lint

func (c *Client) Lint() (*LintResponse, error)

Lint fetches GET /api/lint.

func (*Client) Ready

func (c *Client) Ready() (bool, error)

Ready fetches GET /ready.

func (*Client) SecurityEvents

func (c *Client) SecurityEvents(limit int) (*SecurityEventsResponse, error)

SecurityEvents fetches GET /api/security/events.

func (*Client) SecuritySummary

func (c *Client) SecuritySummary() (*SecuritySummaryResponse, error)

SecuritySummary fetches GET /api/security/summary.

func (*Client) Status

func (c *Client) Status() (*StatusResponse, error)

Status fetches GET /api/status.

func (*Client) TimeTravel

func (c *Client) TimeTravel(opts TimeTravelOpts) (*TimeTravelResponse, error)

TimeTravel fetches GET /api/timetravel.

type ConfigAudit

type ConfigAudit struct {
	Enabled   bool `json:"enabled"`
	DualWrite bool `json:"dual_write"`
}

ConfigAudit holds sanitized audit settings.

type ConfigDaemon

type ConfigDaemon struct {
	Bind      string `json:"bind"`
	Port      int    `json:"port"`
	LogLevel  string `json:"log_level"`
	Mode      string `json:"mode"`
	QueueSize int    `json:"queue_size"`
}

ConfigDaemon holds sanitized daemon settings.

type ConfigEmbedding

type ConfigEmbedding struct {
	Enabled    bool   `json:"enabled"`
	Provider   string `json:"provider"`
	Model      string `json:"model"`
	Dimensions int    `json:"dimensions"`
}

ConfigEmbedding holds sanitized embedding settings.

type ConfigMCP

type ConfigMCP struct {
	Enabled    bool   `json:"enabled"`
	Port       int    `json:"port"`
	Bind       string `json:"bind"`
	SourceName string `json:"source_name"`
}

ConfigMCP holds sanitized MCP settings.

type ConfigRateLimit

type ConfigRateLimit struct {
	GlobalRPM int `json:"global_rpm"`
}

ConfigRateLimit holds sanitized rate limit settings.

type ConfigResponse

type ConfigResponse struct {
	Daemon       ConfigDaemon    `json:"daemon"`
	WAL          ConfigWAL       `json:"wal"`
	MCP          ConfigMCP       `json:"mcp"`
	Web          ConfigWeb       `json:"web"`
	Embedding    ConfigEmbedding `json:"embedding"`
	TLS          ConfigTLS       `json:"tls"`
	RateLimit    ConfigRateLimit `json:"rate_limit"`
	Retrieval    ConfigRetrieval `json:"retrieval"`
	Audit        ConfigAudit     `json:"audit"`
	Sources      []string        `json:"sources"`
	Destinations []string        `json:"destinations"`
}

ConfigResponse is the shape of GET /api/config. Contains sanitized config — NEVER includes secrets.

type ConfigRetrieval

type ConfigRetrieval struct {
	TimeDecay      bool    `json:"time_decay"`
	HalfLifeDays   float64 `json:"half_life_days"`
	DefaultProfile string  `json:"default_profile"`
}

ConfigRetrieval holds sanitized retrieval settings.

type ConfigTLS

type ConfigTLS struct {
	Enabled    bool   `json:"enabled"`
	MinVersion string `json:"min_version"`
}

ConfigTLS holds sanitized TLS settings.

type ConfigWAL

type ConfigWAL struct {
	Path              string `json:"path"`
	MaxSegmentSizeMB  int64  `json:"max_segment_size_mb"`
	IntegrityMode     string `json:"integrity_mode"`
	EncryptionEnabled bool   `json:"encryption_enabled"`
	WatchdogIntervalS int    `json:"watchdog_interval_s"`
	WatchdogMinDisk   int64  `json:"watchdog_min_disk"`
}

ConfigWAL holds sanitized WAL settings.

type ConfigWeb

type ConfigWeb struct {
	Port        int  `json:"port"`
	RequireAuth bool `json:"require_auth"`
}

ConfigWeb holds sanitized web dashboard settings.

type ConflictEntry

type ConflictEntry struct {
	Subject           string      `json:"subject"`
	EntityKey         string      `json:"entity_key"`
	ConflictingValues []string    `json:"conflicting_values"`
	Sources           []string    `json:"sources"`
	Timestamps        []time.Time `json:"timestamps"`
	Count             int         `json:"count"`
}

ConflictEntry is a single conflict group. Matches destination.ConflictGroup from the server.

type ConflictOpts

type ConflictOpts struct {
	Limit int
}

ConflictOpts are query parameters for conflicts.

type ConflictsResponse

type ConflictsResponse struct {
	Conflicts []ConflictEntry `json:"conflicts"`
	Count     int             `json:"count"`
}

ConflictsResponse is the shape of GET /api/conflicts.

type HealthResponse

type HealthResponse struct {
	Status  string `json:"status"`
	Version string `json:"version"`
}

HealthResponse is the shape of GET /health.

type LintFinding

type LintFinding struct {
	Severity string `json:"severity"`
	Check    string `json:"check"`
	Message  string `json:"message"`
}

LintFinding is a single lint finding.

type LintResponse

type LintResponse struct {
	Findings []LintFinding `json:"findings"`
}

LintResponse is the shape of GET /api/lint.

type SecurityEvent

type SecurityEvent struct {
	EventType string                 `json:"event_type"`
	Source    string                 `json:"source,omitempty"`
	Subject   string                 `json:"subject,omitempty"`
	IP        string                 `json:"ip,omitempty"`
	Endpoint  string                 `json:"endpoint,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
	Details   map[string]interface{} `json:"details,omitempty"`
}

SecurityEvent is a single security event. Matches securitylog.Event from the server.

type SecurityEventsResponse

type SecurityEventsResponse struct {
	Events []SecurityEvent `json:"events"`
}

SecurityEventsResponse is the shape of GET /api/security/events.

type SecuritySummaryResponse

type SecuritySummaryResponse struct {
	AuthFailures              int            `json:"auth_failures"`
	PolicyDenials             int            `json:"policy_denials"`
	RateLimitHits             int            `json:"rate_limit_hits"`
	WALTamperDetected         int            `json:"wal_tamper_detected"`
	ConfigSignatureInvalid    int            `json:"config_signature_invalid"`
	AdminAccess               int            `json:"admin_access"`
	RetrievalFirewallFiltered int            `json:"retrieval_firewall_filtered"`
	RetrievalFirewallDenied   int            `json:"retrieval_firewall_denied"`
	BySource                  map[string]int `json:"by_source"`
}

SecuritySummaryResponse is the shape of GET /api/security/summary.

type StatusResponse

type StatusResponse struct {
	Status           string  `json:"status"`
	Version          string  `json:"version"`
	QueueDepth       int     `json:"queue_depth"`
	ConsistencyScore float64 `json:"consistency_score"`
}

StatusResponse is the shape of GET /api/status.

type TimeTravelOpts

type TimeTravelOpts struct {
	AsOf    string
	Subject string
	Limit   int
}

TimeTravelOpts are query parameters for time-travel.

type TimeTravelRecord

type TimeTravelRecord struct {
	PayloadID        string    `json:"payload_id"`
	RequestID        string    `json:"request_id"`
	Source           string    `json:"source"`
	Subject          string    `json:"subject"`
	Namespace        string    `json:"namespace"`
	Destination      string    `json:"destination"`
	Collection       string    `json:"collection"`
	Content          string    `json:"content"`
	Model            string    `json:"model"`
	Role             string    `json:"role"`
	Timestamp        time.Time `json:"timestamp"`
	IdempotencyKey   string    `json:"idempotency_key"`
	SchemaVersion    int       `json:"schema_version"`
	TransformVersion string    `json:"transform_version"`
	ActorType        string    `json:"actor_type"`
	ActorID          string    `json:"actor_id"`
}

TimeTravelRecord is a single time-travel record. Matches destination.TranslatedPayload from the server.

type TimeTravelResponse

type TimeTravelResponse struct {
	AsOf       string             `json:"as_of"`
	HasMore    bool               `json:"has_more"`
	NextCursor string             `json:"next_cursor"`
	Records    []TimeTravelRecord `json:"records"`
}

TimeTravelResponse is the shape of GET /api/timetravel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL