Documentation
¶
Index ¶
- Constants
- func AddDbServer(ctx context.Context, ref dto.ProjectRef, projDbServer datatug.ProjDbServer) error
- func AddRowsToRecordset(params RecordsetDataRequestParams, _ []RowValues) (numberOfRecords int, err error)
- func ConfigureSecureSession(session secureread.Session, pathsByID map[string]string)
- func CreateBoard(ctx context.Context, ref dto.ProjectRef, board datatug.Board) (*datatug.Board, error)
- func CreateFolder(ctx context.Context, request dto.CreateFolder) (folder *datatug.Folder, err error)
- func CreateProject(ctx context.Context, request dto.CreateProjectRequest) (*datatug.ProjectSummary, error)
- func CreateQuery(ctx context.Context, request dto.CreateQuery) (*datatug.QueryDefWithFolderPath, error)
- func DeleteBoard(ctx context.Context, ref dto.ProjectItemRef) error
- func DeleteDbServer(ctx context.Context, ref dto.ProjectRef, dbServer datatug.ServerRef) (err error)
- func DeleteEntity(ctx context.Context, ref dto.ProjectItemRef) error
- func DeleteFolder(ctx context.Context, ref dto.ProjectItemRef) error
- func DeleteQuery(ctx context.Context, ref dto.ProjectItemRef) error
- func ExecuteCommands(ctx context.Context, storeID string, request sqlexecute.Request) (response sqlexecute.Response, err error)
- func GetAllEntities(ctx context.Context, ref dto.ProjectRef) (entity datatug.Entities, err error)
- func GetBoard(ctx context.Context, ref dto.ProjectItemRef) (*datatug.Board, error)
- func GetDatasetDefinition(ctx context.Context, ref dto.ProjectItemRef) (dataset *datatug.RecordsetDefinition, err error)
- func GetDbServerSummary(ctx context.Context, ref dto.ProjectRef, dbServer datatug.ServerRef) (*datatug.ProjDbServer, error)
- func GetEntity(ctx context.Context, ref dto.ProjectItemRef) (entity *datatug.Entity, err error)
- func GetEnvironmentSummary(ctx context.Context, ref dto.ProjectItemRef) (*datatug.EnvironmentSummary, error)
- func GetProjectFull(ctx context.Context, ref dto.ProjectRef) (*datatug.Project, error)
- func GetProjectSummary(ctx context.Context, ref dto.ProjectRef) (projSummary *datatug.ProjectSummary, err error)
- func GetProjects(ctx context.Context, storeID string) ([]datatug.ProjectBrief, error)
- func GetQuery(ctx context.Context, ref dto.ProjectItemRef) (query *datatug.QueryDefWithFolderPath, err error)
- func GetRecordset(_ context.Context, _ dto.ProjectItemRef) (recordset *datatug.Recordset, err error)
- func GetRecordsetsSummary(ctx context.Context, ref dto.ProjectRef) (*dto.ProjRecordsetSummary, error)
- func GetServerDatabases(request dto.GetServerDatabasesRequest) (databases []*datatug.DbCatalog, err error)
- func RemoveRowsFromRecordset(params RecordsetDataRequestParams, rows []RowWithIndex) (numberOfRecordsAffected int, err error)
- func SaveBoard(ctx context.Context, ref dto.ProjectRef, board datatug.Board) (*datatug.Board, error)
- func SaveEntity(ctx context.Context, ref dto.ProjectRef, entity *datatug.Entity) error
- func SecureExecutor() (*secureread.Executor, bool)
- func SecurePrincipalID() string
- func UpdateDbSchema(ctx context.Context, projectLoader ProjectLoader, ...) (project *datatug.Project, err error)
- func UpdateDbServer(ctx context.Context, ref dto.ProjectRef, projDbServer datatug.ProjDbServer) error
- func UpdateQuery(ctx context.Context, request dto.UpdateQuery) (*datatug.QueryDefWithFolderPath, error)
- func UpdateRowsInRecordset(params RecordsetDataRequestParams, rows []RowWithIndexAndNewValues) (numberOfRecordsAffected int, err error)
- type AgentInfo
- type LimitationDTO
- type ProjectLoader
- type QueryResultResponse
- type RecordsetDataRequestParams
- type RecordsetRequestParams
- type RowValues
- type RowWithIndex
- type RowWithIndexAndNewValues
- type RunQueryRequest
- type RunQueryResponse
- type SelectRequest
Constants ¶
const DataTugAgentVersion = "0.0.1"
DataTugAgentVersion specifies agent version
Variables ¶
This section is empty.
Functions ¶
func AddDbServer ¶
func AddDbServer(ctx context.Context, ref dto.ProjectRef, projDbServer datatug.ProjDbServer) error
AddDbServer adds db server to project
func AddRowsToRecordset ¶
func AddRowsToRecordset(params RecordsetDataRequestParams, _ []RowValues) (numberOfRecords int, err error)
AddRowsToRecordset adds rows to a recordset
func ConfigureSecureSession ¶ added in v0.16.0
func ConfigureSecureSession(session secureread.Session, pathsByID map[string]string)
ConfigureSecureSession wires the fixed secureread.Session `datatug serve` builds once for its whole process lifetime (REQ:principal-selection) into every request this process handles, and records the project-id -> filesystem-directory map serve already resolved (pathsByID) so a saved query's SQL/DTQL sidecar file can be located — pkg/datatug-core's LoadQuery does not hydrate QueryDef.Text back from that file yet (that lands with the datatug-core sidecar-read story; see loadQueryDocument).
Every request-handling call site MUST go through SecureExecutor rather than open a source or run a query directly, so every read really does pass through the one policy-enforced path (REQ:server-acl-all-reads).
func CreateBoard ¶
func CreateBoard(ctx context.Context, ref dto.ProjectRef, board datatug.Board) (*datatug.Board, error)
CreateBoard creates board
func CreateFolder ¶
func CreateFolder(ctx context.Context, request dto.CreateFolder) (folder *datatug.Folder, err error)
CreateFolder creates a new folder for queries
func CreateProject ¶
func CreateProject(ctx context.Context, request dto.CreateProjectRequest) (*datatug.ProjectSummary, error)
CreateProject create a new DataTug project using requested store
func CreateQuery ¶
func CreateQuery(ctx context.Context, request dto.CreateQuery) (*datatug.QueryDefWithFolderPath, error)
CreateQuery creates a new query
func DeleteBoard ¶
func DeleteBoard(ctx context.Context, ref dto.ProjectItemRef) error
DeleteBoard deletes board
func DeleteDbServer ¶
func DeleteDbServer(ctx context.Context, ref dto.ProjectRef, dbServer datatug.ServerRef) (err error)
DeleteDbServer adds db server to project
func DeleteEntity ¶
func DeleteEntity(ctx context.Context, ref dto.ProjectItemRef) error
DeleteEntity deletes board
func DeleteFolder ¶
func DeleteFolder(ctx context.Context, ref dto.ProjectItemRef) error
DeleteFolder deletes queries folder
func DeleteQuery ¶
func DeleteQuery(ctx context.Context, ref dto.ProjectItemRef) error
DeleteQuery deletes query
func ExecuteCommands ¶
func ExecuteCommands(ctx context.Context, storeID string, request sqlexecute.Request) (response sqlexecute.Response, err error)
ExecuteCommands executes command
func GetAllEntities ¶
GetAllEntities returns all entities
func GetDatasetDefinition ¶
func GetDatasetDefinition(ctx context.Context, ref dto.ProjectItemRef) (dataset *datatug.RecordsetDefinition, err error)
GetDatasetDefinition returns definition of a dataset by ID
func GetDbServerSummary ¶
func GetDbServerSummary(ctx context.Context, ref dto.ProjectRef, dbServer datatug.ServerRef) (*datatug.ProjDbServer, error)
GetDbServerSummary returns summary on DB server
func GetEnvironmentSummary ¶
func GetEnvironmentSummary(ctx context.Context, ref dto.ProjectItemRef) (*datatug.EnvironmentSummary, error)
GetEnvironmentSummary returns environment summary
func GetProjectFull ¶
GetProjectFull returns full project metadata
func GetProjectSummary ¶
func GetProjectSummary(ctx context.Context, ref dto.ProjectRef) (projSummary *datatug.ProjectSummary, err error)
GetProjectSummary returns project summary
func GetProjects ¶
GetProjects return all projects
func GetQuery ¶
func GetQuery(ctx context.Context, ref dto.ProjectItemRef) (query *datatug.QueryDefWithFolderPath, err error)
GetQuery returns query definition
func GetRecordset ¶
func GetRecordset(_ context.Context, _ dto.ProjectItemRef) (recordset *datatug.Recordset, err error)
GetRecordset saves board
func GetRecordsetsSummary ¶
func GetRecordsetsSummary(ctx context.Context, ref dto.ProjectRef) (*dto.ProjRecordsetSummary, error)
GetRecordsetsSummary returns board by ID
func GetServerDatabases ¶
func GetServerDatabases(request dto.GetServerDatabasesRequest) (databases []*datatug.DbCatalog, err error)
GetServerDatabases returns list of databases hosted at a server
func RemoveRowsFromRecordset ¶
func RemoveRowsFromRecordset(params RecordsetDataRequestParams, rows []RowWithIndex) (numberOfRecordsAffected int, err error)
RemoveRowsFromRecordset removes rows from a recordset
func SaveBoard ¶
func SaveBoard(ctx context.Context, ref dto.ProjectRef, board datatug.Board) (*datatug.Board, error)
SaveBoard saves board
func SaveEntity ¶
SaveEntity saves board
func SecureExecutor ¶ added in v0.16.0
func SecureExecutor() (*secureread.Executor, bool)
SecureExecutor returns the Executor ConfigureSecureSession built, and false when serve has not configured one yet (e.g. a handler under test with no ConfigureSecureSession call).
func SecurePrincipalID ¶ added in v0.16.0
func SecurePrincipalID() string
SecurePrincipalID returns the serving principal's ID for `agent-info` to report (REQ:principal-selection), or "" when the session carries no identified principal (Unrestricted with no --as, or a role/group-only principal).
func UpdateDbSchema ¶
func UpdateDbSchema(ctx context.Context, projectLoader ProjectLoader, projectID, environment, driver, dbModelID string, dbConnParams dbconnection.Params) (project *datatug.Project, err error)
UpdateDbSchema updates DB schema
func UpdateDbServer ¶
func UpdateDbServer(ctx context.Context, ref dto.ProjectRef, projDbServer datatug.ProjDbServer) error
UpdateDbServer adds db server to project
func UpdateQuery ¶
func UpdateQuery(ctx context.Context, request dto.UpdateQuery) (*datatug.QueryDefWithFolderPath, error)
UpdateQuery updates existing query
func UpdateRowsInRecordset ¶
func UpdateRowsInRecordset(params RecordsetDataRequestParams, rows []RowWithIndexAndNewValues) (numberOfRecordsAffected int, err error)
UpdateRowsInRecordset updates rows in a recordset
Types ¶
type AgentInfo ¶
type AgentInfo struct {
Version string `json:"version"`
UptimeMinutes float64 `json:"uptimeMinutes"`
// Principal is the serving principal's ID (REQ:principal-selection); ""
// when the session carries no identified principal (Unrestricted with no
// --as, or a role/group-only principal). The web UI displays this and
// MUST NOT be able to change it — no endpoint accepts a principal from
// the request.
Principal string `json:"principal,omitempty"`
}
AgentInfo holds agent info
type LimitationDTO ¶ added in v0.16.0
type LimitationDTO struct {
Kind string `json:"kind"`
Policy string `json:"policy,omitempty"`
Note string `json:"note,omitempty"`
Columns []string `json:"columns,omitempty"`
Count *int `json:"count,omitempty"`
}
LimitationDTO mirrors secureread.Limitation for JSON. Kind is one of "policy", "rowsFiltered", "hiddenColumns" or "nativeSql" (secureread.LimitationKind); which of Policy/Note/Columns/Count is set depends on Kind exactly as documented on secureread.Limitation.
type ProjectLoader ¶
type ProjectLoader interface {
LoadProjectFile(ctx context.Context) (projectFile datatug.ProjectFile, err error)
LoadProject(ctx context.Context, o ...datatug.StoreOption) (project *datatug.Project, err error)
}
ProjectLoader defines an interface to load project info
type QueryResultResponse ¶ added in v0.16.0
type QueryResultResponse struct {
Columns []string `json:"columns"`
Rows []map[string]any `json:"rows"`
Limitations []LimitationDTO `json:"limitations,omitempty"`
}
QueryResultResponse is the JSON shape every policy-enforced read endpoint returns: the columns and rows the principal is allowed to see, plus the limitations that were applied producing them (REQ:limitation-visible — "every result MUST carry the policy limitations applied ... rather than have applied silently"). It is the direct serialization of secureread.Result; see LimitationDTO for the per-entry shape.
func ExecuteSelect ¶
func ExecuteSelect(ctx context.Context, storeID string, request SelectRequest) (QueryResultResponse, error)
ExecuteSelect executes a select through the policy-enforced secureread.Executor (REQ:server-acl-all-reads): a "from" selection runs through RunStructured, raw "sql" text through RunNativeSQL. Every read the web UI can trigger through `datatug serve` MUST come through this one path — see routes.go's executeRoutes / execute_endpoints.go.
type RecordsetDataRequestParams ¶
type RecordsetDataRequestParams struct {
RecordsetRequestParams
Data string `json:"data"`
}
RecordsetDataRequestParams is a set of common request parameters
func (RecordsetDataRequestParams) Validate ¶
func (v RecordsetDataRequestParams) Validate() error
Validate returns error if not valid
type RecordsetRequestParams ¶
type RecordsetRequestParams struct {
Project string `json:"project"`
Recordset string `json:"recordset"`
}
RecordsetRequestParams is a set of common request parameters
func (RecordsetRequestParams) Validate ¶
func (v RecordsetRequestParams) Validate() error
Validate returns error if not valid
type RowWithIndex ¶
RowWithIndex points to specific row with expected values
func (RowWithIndex) Validate ¶
func (v RowWithIndex) Validate() error
Validate returns error if not valid
type RowWithIndexAndNewValues ¶
type RowWithIndexAndNewValues struct {
RowWithIndex
NewValues map[string]interface{} `json:"newValues"`
}
RowWithIndexAndNewValues points to specific row with expected values and provides new set of named values
type RunQueryRequest ¶ added in v0.16.0
type RunQueryRequest struct {
StoreID string `json:"storage"`
ProjectID string `json:"project"`
Environment string `json:"environment"`
Database string `json:"database"`
QueryID string `json:"queryId,omitempty"`
DTQL string `json:"dtql,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
}
RunQueryRequest is the body of POST /datatug/exec/run_query: run a saved query (QueryID, resolved via the project store) or an ad-hoc DTQL document (DTQL, raw DTQL-YAML text) against Environment/Database, with Parameters bound as the query's own `param` nodes (including $currentUser, bound automatically from the session's principal — see pkg/accesspolicies.Run/secureread.Executor.RunDTQL).
func (RunQueryRequest) Validate ¶ added in v0.16.0
func (v RunQueryRequest) Validate() error
Validate returns an error if the request is not well-formed.
type RunQueryResponse ¶ added in v0.16.0
type RunQueryResponse struct {
QueryResultResponse
BindingsApplied map[string]any `json:"bindingsApplied,omitempty"`
}
RunQueryResponse is POST /datatug/exec/run_query's response: the recordset and limitations every policy-enforced read carries (QueryResultResponse), plus the parameter values that were actually bound into the run.
func RunQuery ¶ added in v0.16.0
func RunQuery(ctx context.Context, request RunQueryRequest) (RunQueryResponse, error)
RunQuery dispatches a saved or ad-hoc query through the policy-enforced secureread.Executor (REQ:server-acl-all-reads, REQ:dtql-query-type): a saved SQL query runs through RunNativeSQL, a saved or ad-hoc DTQL document through RunDTQL. It is the one implementation POST /datatug/exec/run_query and (indirectly, via the same dispatch shape) saved-query runs elsewhere must funnel through.
type SelectRequest ¶
type SelectRequest struct {
Project string
Environment string
Database string
From string
SQL string
Where string
Limit int
Columns []string
}
SelectRequest holds request data for GET /datatug/exec/select.
func (SelectRequest) Validate ¶
func (v SelectRequest) Validate() error
Validate returns error if not valid