endpoints

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

README

API end-points of DataTug agent

When DataTug agent is started with a serve command it listens on HTTP port (by default 8989).

datatug serve -p=./example

Endpoints

Method Path Description
Executor
POST /exec/execute Executes a batch of commands
GET /exec/select Executes a single non mutating SELECT command
Entities
GET /entities/all_entities
GET /entities/entity
POST /entities/create_entity
PUT /entities/save_entity
DELETE /entities/delete_entity
Queries
GET /queries/all_queries
POST /queries/create_query
PUT /queries/save_query
DELETE /queries/delete_query
Recordsets
GET /data/recordsets
GET /data/recordset_definition
GET /data/recordset_data
POST /data/recordset_add_rows
PUT /data/recordset_update_rows
DELETE /data/recordset_delete_rows
Boards
GET /boards/board
POST /boards/create_board
PUT /boards/save_board
DELETE /boards/delete_board
Endpoint: POST /execute

Executes a batch of commands

Endpoint: GET /select

Executes a single non mutating SELECT command

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentInfo

func AgentInfo(w http.ResponseWriter, r *http.Request)

AgentInfo returns version of the agent

func IsSupportedOrigin

func IsSupportedOrigin(origin string) bool

IsSupportedOrigin check provided origin is allowed

func Ping

func Ping(w http.ResponseWriter, _ *http.Request)

Ping return "pong" - is a simplest

func RegisterDatatugHandlers

func RegisterDatatugHandlers(
	pathPrefix string,
	router *httprouter.Router,
	mode RegisterMode,
	wrap wrapper,
	contextProvider func(r *http.Request) (context.Context, error),
	handler Handler,
)

RegisterDatatugHandlers registers datatug HTTP handlers

Types

type ApplicableEntry added in v0.17.0

type ApplicableEntry struct {
	Query    string       `json:"query"`
	Bindings []BindingDTO `json:"bindings"`
	Chain    []string     `json:"chain"`
}

ApplicableEntry is one query every required semantically-tagged parameter of which could be bound. Query is the query's ID (its ProjectItem.ID) — callers already have GET /datatug/queries/get_query to fetch the rest.

type ApplicableRequest added in v0.17.0

type ApplicableRequest struct {
	Values []ApplicableValue `json:"values"`
}

ApplicableRequest is POST /datatug/queries/applicable's body: per the API contracts table, {values: [{entity, field, value, origin}]}. Origin is accepted (the web Investigation Context tags where a value came from) but not used by semantic.Applicable's own logic; it is not echoed back either, since Applicable does not thread it through.

type ApplicableResponse added in v0.17.0

type ApplicableResponse struct {
	Applicable []ApplicableEntry `json:"applicable"`
	NotYet     []NotYetEntry     `json:"notYet"`
}

ApplicableResponse is POST /datatug/queries/applicable's response: per the API contracts table, {applicable: [{query, bindings, chain}], notYet: [{query, missing}]}.

type ApplicableValue added in v0.17.0

type ApplicableValue struct {
	Entity     string `json:"entity"`
	Field      string `json:"field"`
	Value      any    `json:"value"`
	Source     string `json:"source"`
	Collection string `json:"collection"`
	Column     string `json:"column"`
	Provenance string `json:"provenance"`
	Origin     string `json:"origin,omitempty"`
}

ApplicableValue is one semantic value on hand (the current selection, or an item from the Investigation Context). Source/Collection/Column/ Provenance are required: they are exactly semantic.SemanticValue's own required fields (used to attribute a bound parameter's origin in the resolution Chain), not optional metadata.

type BindingDTO added in v0.17.0

type BindingDTO struct {
	Parameter string `json:"parameter"`
	Value     any    `json:"value"`
}

BindingDTO is one bound parameter.

type ColumnResolution added in v0.17.0

type ColumnResolution struct {
	Column     string `json:"column"`
	Entity     string `json:"entity,omitempty"`
	Field      string `json:"field,omitempty"`
	Provenance string `json:"provenance,omitempty"`
	Rule       string `json:"rule,omitempty"`
	Error      string `json:"error,omitempty"`
}

ColumnResolution is one column's resolution. Error is set only when a column had NamePatterns candidates that failed to evaluate (e.g. invalid regexp) and nothing else resolved it — semantic.Resolution.Err's case; Entity/Field/Provenance/Rule are empty in that case.

type ColumnsResponse added in v0.17.0

type ColumnsResponse struct {
	Columns []ColumnResolution `json:"columns"`
}

ColumnsResponse is GET /datatug/semantic/columns's body: per REQ:semantic- resolution-endpoint and the API contracts table, [{column, entity, field, provenance}] — Rule is this stream's own addition (brief item 1 lists it explicitly; it is directly available from semantic.Resolution.Rule and documents *why* a column resolved the way it did, useful beyond what the hub table's abbreviated shape shows).

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
	Code  string `json:"code,omitempty"`
	Field string `json:"field,omitempty"`
}

ErrorResponse defines format of error response body. Code is set for a structured refusal (currently only "ACCESS_DENIED"); Field is reserved for a future per-field validation error and is not populated yet.

type Handler

type Handler = func(
	w http.ResponseWriter,
	r *http.Request,
	requestDTO apicore.RequestDTO,
	verifyOptions verify.RequestOptions,
	successStatusCode int,
	getContext apicore.ContextProvider,
	handler apicore.Worker,
)

Handler is responsible for creating context and call `handler()` func that should use provided context along with `requestDTO` that was populated from request body Its is exposed publicly so it can be replaced with custom implementation

type NotYetEntry added in v0.17.0

type NotYetEntry struct {
	Query   string   `json:"query"`
	Missing []string `json:"missing"`
}

NotYetEntry is one query still missing at least one required semantically- tagged parameter.

type ProjectAgentEndpoints

type ProjectAgentEndpoints struct {
}

ProjectAgentEndpoints defines project endpoints

type ProjectEndpoints

type ProjectEndpoints interface {
	CreateProject(w http.ResponseWriter, r *http.Request)
	DeleteProject(w http.ResponseWriter, r *http.Request)
}

ProjectEndpoints defines project endpoints

type RegisterMode

type RegisterMode = int
const (
	RegisterWriteOnlyHandlers RegisterMode = iota
	RegisterAllHandlers
)

type RelatedEntry added in v0.17.0

type RelatedEntry struct {
	Label      string `json:"label"`
	Source     string `json:"source"`
	Collection string `json:"collection"`
	Column     string `json:"column"`
	Kind       string `json:"kind"`
	Count      *int   `json:"count"`
	LookupID   string `json:"lookupId"`
}

RelatedEntry is one related-record path. Label defaults to Collection — semantic.Lookup carries no human title of its own, and no entity/board naming convention exists yet to derive a nicer one from; a caller free to override display text with something richer once one does.

Count is nil ("count unavailable" in the hub's own wording) whenever running the count query through the access-policy path reported any Limitation — a restricted count is not the true count, so REQ:related- lookup-execution's "count or count unavailable" is honoured by refusing to report a number that would misrepresent what an unrestricted caller would see. It is also nil if the count query itself failed (e.g. access denied outright): the /related endpoint reports "nothing to show", it does not fail the whole list over one lookup a principal cannot see at all.

type RelatedResponse added in v0.17.0

type RelatedResponse struct {
	Related []RelatedEntry `json:"related"`
}

RelatedResponse is GET /datatug/semantic/related's body: per REQ:related- lookup-model and the API contracts table, [{label, source, collection, count|null, lookupId}]. Column/Kind are this stream's own addition, directly available from semantic.Lookup and useful for a caller (the web context panel) that wants to explain a lookup rather than just list it.

type RelatedRow added in v0.17.0

type RelatedRow struct {
	Key  string         `json:"key"`
	Data map[string]any `json:"data"`
}

RelatedRow mirrors secureread.Row (Key/Data) under its own JSON tags — secureread.Row has none of its own (see PR body: modifying pkg/secureread, already merged by a concurrent lane, is outside this stream's scope).

type RelatedRowsResponse added in v0.17.0

type RelatedRowsResponse struct {
	Columns     []string                `json:"columns"`
	Rows        []RelatedRow            `json:"rows"`
	Limitations []secureread.Limitation `json:"limitations"`
}

RelatedRowsResponse is GET /datatug/semantic/related/rows's body: per the API contracts table, "recordset + limitations".

type VerifyRequest

type VerifyRequest struct {
	MinContentLength int64
	MaxContentLength int64
	AuthRequired     bool
}

VerifyRequest implements VerifyRequestOptions

func (VerifyRequest) AuthenticationRequired

func (v VerifyRequest) AuthenticationRequired() bool

AuthenticationRequired specifies if authentication is mandatory

func (VerifyRequest) MaximumContentLength

func (v VerifyRequest) MaximumContentLength() int64

MaximumContentLength defines max content length, if < 0 no limit

func (VerifyRequest) MinimumContentLength

func (v VerifyRequest) MinimumContentLength() int64

MinimumContentLength defines min content length

Jump to

Keyboard shortcuts

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