endpoints

package
v0.46.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 60 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 Legacy create-or-replace; needs --allow-writes and a project-write grant for the serving principal
PUT /queries/update_query Legacy create-or-replace; same authorization as create_query
DELETE /queries/delete_query Needs --allow-writes and a project-write grant
POST /queries/capture Save as project query: an atomic, revision-checked create (ifNoneMatch) or update (ifMatch) of a DTQL query pair; same authorization
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

View Source
var ErrInvalidQueriesRoot = errors.New("invalid queries root")

ErrInvalidQueriesRoot is handleError's INVALID_REQUEST trigger (field "root") for an unrecognized ?root= value — the same {code,field} shape api.ErrUnknownStoreID/ErrAmbiguousStore already give ?storage=.

Functions

func AgentInfo

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

AgentInfo is GET agent-info's exact contract envelope (api-contract.md "Endpoint table"): principal with explicit roles/groups, securityContextId, the projects this process serves, and its capabilities. It replaces the old ad-hoc {version, uptimeMinutes, principal} shape (pkg/api.GetAgentInfo/AgentInfo) — Task 12 item 3.

version reports buildinfo.Get("datatug").Version — see buildInfoFunc. The contract (api-contract.md "Endpoint table", `agent-info` row) defines only `version` on this envelope; commit and build date are deliberately not added here, even though buildinfo.Info carries them, to avoid introducing fields the contract doesn't define.

func IsSupportedOrigin

func IsSupportedOrigin(origin string) bool

IsSupportedOrigin check provided origin is allowed. 127.0.0.1 is accepted interchangeably with localhost (lane C5, datatug-apps PR #59, verified with curl: a dev server or UI addressing the agent via 127.0.0.1 was refused even though the equivalent localhost origin was already 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 with every write route closed (Capabilities{}) — kept for callers (this package's own tests) that do not need write access. Real `datatug serve` startup uses RegisterDatatugHandlersWithCapabilities.

func RegisterDatatugHandlersWithCapabilities added in v0.20.0

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

RegisterDatatugHandlersWithCapabilities is RegisterDatatugHandlers plus an explicit Capabilities gate for this process's mutation routes.

Types

type Capabilities added in v0.20.0

type Capabilities struct {
	AllowWrites bool
}

Capabilities gates whether this process's mutation routes register at all (api-contract.md "Security and errors": "this read journey must not expose an unauthenticated mutation endpoint as a side effect" — REQ:principal-selection: "Unneeded write endpoints MUST fail closed"). AllowWrites defaults false: a `datatug serve` process serving the Phase 1 read journey registers every mutation route behind requireWriteCapability (write_capability.go), which refuses with ACCESS_DENIED before any project file is touched, unless the caller explicitly opted in (see cmd_serve.go's --allow-writes flag).

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 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 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