Documentation
¶
Index ¶
- type BatchMode
- type ContractHandler
- func (h *ContractHandler) DiffService(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) GetContract(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) ListContracts(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) LockService(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) LockTable(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) PromoteTable(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) SetLockMode(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) UnlockService(w http.ResponseWriter, r *http.Request)
- func (h *ContractHandler) UnlockTable(w http.ResponseWriter, r *http.Request)
- type OpenAPIHandler
- type ProcHandler
- type SchemaHandler
- func (h *SchemaHandler) AlterTable(w http.ResponseWriter, r *http.Request)
- func (h *SchemaHandler) CreateTable(w http.ResponseWriter, r *http.Request)
- func (h *SchemaHandler) DropTable(w http.ResponseWriter, r *http.Request)
- func (h *SchemaHandler) GetTableSchema(w http.ResponseWriter, r *http.Request)
- func (h *SchemaHandler) ListTables(w http.ResponseWriter, r *http.Request)
- type SystemHandler
- func (h *SystemHandler) CreateAPIKey(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) CreateAdmin(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) CreateRole(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) CreateService(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) DeleteRole(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) DeleteService(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) GetRole(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) GetService(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) ListAPIKeys(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) ListAdmins(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) ListRoles(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) ListServices(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) Login(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) Logout(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) MCPInfo(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) RevokeAPIKey(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) SetupCreateAdmin(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) SetupStatus(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) TestConnection(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) UpdateRole(w http.ResponseWriter, r *http.Request)
- func (h *SystemHandler) UpdateService(w http.ResponseWriter, r *http.Request)
- type TableHandler
- func (h *TableHandler) CreateRecords(w http.ResponseWriter, r *http.Request)
- func (h *TableHandler) DeleteRecords(w http.ResponseWriter, r *http.Request)
- func (h *TableHandler) ListTableNames(w http.ResponseWriter, r *http.Request)
- func (h *TableHandler) QueryRecords(w http.ResponseWriter, r *http.Request)
- func (h *TableHandler) ReplaceRecords(w http.ResponseWriter, r *http.Request)
- func (h *TableHandler) UpdateRecords(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchMode ¶ added in v0.1.5
type BatchMode int
BatchMode controls how batch operations handle errors.
const ( // BatchModeHalt stops at the first error (default). Prior operations are committed. BatchModeHalt BatchMode = iota // BatchModeRollback wraps all operations in a transaction and rolls back on any error. BatchModeRollback // BatchModeContinue processes all operations, collecting errors for mixed results. BatchModeContinue )
type ContractHandler ¶ added in v0.1.6
type ContractHandler struct {
// contains filtered or unexported fields
}
ContractHandler manages schema contract locking operations.
func NewContractHandler ¶ added in v0.1.6
func NewContractHandler(registry *connector.Registry, store *config.Store) *ContractHandler
NewContractHandler creates a new ContractHandler.
func (*ContractHandler) DiffService ¶ added in v0.1.6
func (h *ContractHandler) DiffService(w http.ResponseWriter, r *http.Request)
DiffService compares all locked contracts against the live schema. GET /api/v1/system/contract/{serviceName}/diff
func (*ContractHandler) GetContract ¶ added in v0.1.6
func (h *ContractHandler) GetContract(w http.ResponseWriter, r *http.Request)
GetContract returns a single contract with optional drift check. GET /api/v1/system/contract/{serviceName}/{tableName}
func (*ContractHandler) ListContracts ¶ added in v0.1.6
func (h *ContractHandler) ListContracts(w http.ResponseWriter, r *http.Request)
ListContracts returns all schema contracts for a service. GET /api/v1/system/contract/{serviceName}
func (*ContractHandler) LockService ¶ added in v0.1.6
func (h *ContractHandler) LockService(w http.ResponseWriter, r *http.Request)
LockService creates schema contracts for ALL tables in a service. POST /api/v1/system/contract/{serviceName}
func (*ContractHandler) LockTable ¶ added in v0.1.6
func (h *ContractHandler) LockTable(w http.ResponseWriter, r *http.Request)
LockTable creates a schema contract by snapshotting the current live schema. POST /api/v1/system/contract/{serviceName}/{tableName}
func (*ContractHandler) PromoteTable ¶ added in v0.1.6
func (h *ContractHandler) PromoteTable(w http.ResponseWriter, r *http.Request)
PromoteTable updates a contract to match the current live schema. POST /api/v1/system/contract/{serviceName}/{tableName}/promote
func (*ContractHandler) SetLockMode ¶ added in v0.1.6
func (h *ContractHandler) SetLockMode(w http.ResponseWriter, r *http.Request)
SetLockMode updates the schema_lock mode for a service. PUT /api/v1/system/contract/{serviceName}/mode
func (*ContractHandler) UnlockService ¶ added in v0.1.6
func (h *ContractHandler) UnlockService(w http.ResponseWriter, r *http.Request)
UnlockService removes ALL schema contracts for a service. DELETE /api/v1/system/contract/{serviceName}
func (*ContractHandler) UnlockTable ¶ added in v0.1.6
func (h *ContractHandler) UnlockTable(w http.ResponseWriter, r *http.Request)
UnlockTable removes a schema contract for a single table. DELETE /api/v1/system/contract/{serviceName}/{tableName}
type OpenAPIHandler ¶
type OpenAPIHandler struct {
// contains filtered or unexported fields
}
OpenAPIHandler generates and serves OpenAPI 3.1 specifications dynamically based on introspected database schemas. Each service produces a complete OpenAPI spec with paths for all tables, views, and stored procedures.
func NewOpenAPIHandler ¶
func NewOpenAPIHandler(registry *connector.Registry, store *config.Store) *OpenAPIHandler
NewOpenAPIHandler creates a new OpenAPIHandler.
func (*OpenAPIHandler) ServeCombinedSpec ¶
func (h *OpenAPIHandler) ServeCombinedSpec(w http.ResponseWriter, r *http.Request)
ServeCombinedSpec returns a combined OpenAPI spec covering all registered services. Each service's tables are namespaced under /api/v1/{serviceName}. GET /api/v1/openapi.json
func (*OpenAPIHandler) ServeServiceSpec ¶
func (h *OpenAPIHandler) ServeServiceSpec(w http.ResponseWriter, r *http.Request)
ServeServiceSpec returns the OpenAPI spec for a single service. GET /api/v1/{serviceName}/_doc
type ProcHandler ¶
type ProcHandler struct {
// contains filtered or unexported fields
}
ProcHandler handles stored procedure listing and execution.
func NewProcHandler ¶
func NewProcHandler(registry *connector.Registry) *ProcHandler
NewProcHandler creates a new ProcHandler.
func (*ProcHandler) CallProcedure ¶
func (h *ProcHandler) CallProcedure(w http.ResponseWriter, r *http.Request)
CallProcedure executes a stored procedure with the provided parameters and returns the result set. POST /api/v1/{serviceName}/_proc/{procName}
func (*ProcHandler) ListProcedures ¶
func (h *ProcHandler) ListProcedures(w http.ResponseWriter, r *http.Request)
ListProcedures returns all stored procedures and functions for a service. GET /api/v1/{serviceName}/_proc
type SchemaHandler ¶
type SchemaHandler struct {
// contains filtered or unexported fields
}
SchemaHandler handles schema introspection and DDL operations.
func NewSchemaHandler ¶
func NewSchemaHandler(registry *connector.Registry, store *config.Store) *SchemaHandler
NewSchemaHandler creates a new SchemaHandler.
func (*SchemaHandler) AlterTable ¶
func (h *SchemaHandler) AlterTable(w http.ResponseWriter, r *http.Request)
AlterTable modifies an existing table's schema. The request body should contain an array of schema changes (add_column, drop_column, rename_column, modify_column).
When schema locking is in "strict" mode, AlterTable is blocked entirely. When in "auto" mode, only breaking changes (drop_column, rename_column, modify_column) are blocked; additive changes (add_column) pass through. PUT /api/v1/{serviceName}/_schema/{tableName}
func (*SchemaHandler) CreateTable ¶
func (h *SchemaHandler) CreateTable(w http.ResponseWriter, r *http.Request)
CreateTable creates a new table in the service's database from a table schema definition provided in the request body. POST /api/v1/{serviceName}/_schema
func (*SchemaHandler) DropTable ¶
func (h *SchemaHandler) DropTable(w http.ResponseWriter, r *http.Request)
DropTable removes a table from the service's database.
When schema locking is enabled, dropping a locked table is blocked. DELETE /api/v1/{serviceName}/_schema/{tableName}
func (*SchemaHandler) GetTableSchema ¶
func (h *SchemaHandler) GetTableSchema(w http.ResponseWriter, r *http.Request)
GetTableSchema returns the detailed schema for a single table or view. GET /api/v1/{serviceName}/_schema/{tableName}
func (*SchemaHandler) ListTables ¶
func (h *SchemaHandler) ListTables(w http.ResponseWriter, r *http.Request)
ListTables returns the full schema for a service's database, including all tables, views, stored procedures, and functions.
When schema locking is enabled (auto or strict), the response includes a "contract" field with drift status for each locked table. GET /api/v1/{serviceName}/_schema
type SystemHandler ¶
type SystemHandler struct {
// contains filtered or unexported fields
}
SystemHandler manages Faucet's own configuration: services, roles, admins, and API keys.
func NewSystemHandler ¶
func NewSystemHandler(store *config.Store, authSvc *service.AuthService, registry *connector.Registry) *SystemHandler
NewSystemHandler creates a new SystemHandler.
func (*SystemHandler) CreateAPIKey ¶
func (h *SystemHandler) CreateAPIKey(w http.ResponseWriter, r *http.Request)
CreateAPIKey generates a new API key, hashes it, stores the hash, and returns the plaintext key exactly once. POST /api/v1/system/api_key
func (*SystemHandler) CreateAdmin ¶
func (h *SystemHandler) CreateAdmin(w http.ResponseWriter, r *http.Request)
CreateAdmin creates a new admin account. POST /api/v1/system/admin
func (*SystemHandler) CreateRole ¶
func (h *SystemHandler) CreateRole(w http.ResponseWriter, r *http.Request)
CreateRole creates a new role. POST /api/v1/system/role
func (*SystemHandler) CreateService ¶
func (h *SystemHandler) CreateService(w http.ResponseWriter, r *http.Request)
CreateService registers a new database service. POST /api/v1/system/service
func (*SystemHandler) DeleteRole ¶
func (h *SystemHandler) DeleteRole(w http.ResponseWriter, r *http.Request)
DeleteRole removes a role by ID. DELETE /api/v1/system/role/{roleId}
func (*SystemHandler) DeleteService ¶
func (h *SystemHandler) DeleteService(w http.ResponseWriter, r *http.Request)
DeleteService removes a service and disconnects it. DELETE /api/v1/system/service/{serviceName}
func (*SystemHandler) GetRole ¶
func (h *SystemHandler) GetRole(w http.ResponseWriter, r *http.Request)
GetRole returns a single role by ID. GET /api/v1/system/role/{roleId}
func (*SystemHandler) GetService ¶
func (h *SystemHandler) GetService(w http.ResponseWriter, r *http.Request)
GetService returns a single service by name. GET /api/v1/system/service/{serviceName}
func (*SystemHandler) ListAPIKeys ¶
func (h *SystemHandler) ListAPIKeys(w http.ResponseWriter, r *http.Request)
ListAPIKeys returns all configured API keys (without exposing the actual key). GET /api/v1/system/api_key
func (*SystemHandler) ListAdmins ¶
func (h *SystemHandler) ListAdmins(w http.ResponseWriter, r *http.Request)
ListAdmins returns all admin accounts. GET /api/v1/system/admin
func (*SystemHandler) ListRoles ¶
func (h *SystemHandler) ListRoles(w http.ResponseWriter, r *http.Request)
ListRoles returns all configured roles. GET /api/v1/system/role
func (*SystemHandler) ListServices ¶
func (h *SystemHandler) ListServices(w http.ResponseWriter, r *http.Request)
ListServices returns all configured database services. GET /api/v1/system/service
func (*SystemHandler) Login ¶
func (h *SystemHandler) Login(w http.ResponseWriter, r *http.Request)
Login authenticates an admin user and returns a JWT session token. POST /api/v1/system/admin/session
func (*SystemHandler) Logout ¶
func (h *SystemHandler) Logout(w http.ResponseWriter, r *http.Request)
Logout invalidates the current session. Since JWTs are stateless, this is a no-op on the server side. Clients should discard their token. DELETE /api/v1/system/admin/session
func (*SystemHandler) MCPInfo ¶
func (h *SystemHandler) MCPInfo(w http.ResponseWriter, r *http.Request)
MCPInfo returns the MCP server configuration and connection instructions. GET /api/v1/system/mcp
func (*SystemHandler) RevokeAPIKey ¶
func (h *SystemHandler) RevokeAPIKey(w http.ResponseWriter, r *http.Request)
RevokeAPIKey deactivates an API key by ID. DELETE /api/v1/system/api_key/{keyId}
func (*SystemHandler) SetupCreateAdmin ¶ added in v0.1.5
func (h *SystemHandler) SetupCreateAdmin(w http.ResponseWriter, r *http.Request)
SetupCreateAdmin creates the first admin account during initial setup. This endpoint only works when no admin exists. It creates the admin and returns a JWT session token so the UI can immediately authenticate. POST /api/v1/setup
func (*SystemHandler) SetupStatus ¶ added in v0.1.5
func (h *SystemHandler) SetupStatus(w http.ResponseWriter, r *http.Request)
SetupStatus returns the current setup state of the Faucet instance. GET /api/v1/setup
func (*SystemHandler) TestConnection ¶
func (h *SystemHandler) TestConnection(w http.ResponseWriter, r *http.Request)
TestConnection tests an active service's database connectivity by pinging it. GET /api/v1/system/service/{serviceName}/test
func (*SystemHandler) UpdateRole ¶
func (h *SystemHandler) UpdateRole(w http.ResponseWriter, r *http.Request)
UpdateRole modifies an existing role. PUT /api/v1/system/role/{roleId}
func (*SystemHandler) UpdateService ¶
func (h *SystemHandler) UpdateService(w http.ResponseWriter, r *http.Request)
UpdateService modifies an existing service configuration. PUT /api/v1/system/service/{serviceName}
type TableHandler ¶
type TableHandler struct {
// contains filtered or unexported fields
}
TableHandler handles CRUD operations on database table records.
func NewTableHandler ¶
func NewTableHandler(registry *connector.Registry, store *config.Store) *TableHandler
NewTableHandler creates a new TableHandler.
func (*TableHandler) CreateRecords ¶
func (h *TableHandler) CreateRecords(w http.ResponseWriter, r *http.Request)
CreateRecords inserts one or more records into a table. POST /api/v1/{serviceName}/_table/{tableName}
Batch modes (query parameters):
- (default) halt on first error; prior inserts are committed
- ?rollback=true wrap in transaction; all-or-nothing
- ?continue=true insert each record independently; report mixed results
func (*TableHandler) DeleteRecords ¶
func (h *TableHandler) DeleteRecords(w http.ResponseWriter, r *http.Request)
DeleteRecords removes records matching a filter or ID list. DELETE /api/v1/{serviceName}/_table/{tableName}
Batch modes: ?rollback=true wraps the DELETE in a transaction.
func (*TableHandler) ListTableNames ¶
func (h *TableHandler) ListTableNames(w http.ResponseWriter, r *http.Request)
ListTableNames returns the names of all tables in the service's database. GET /api/v1/{serviceName}/_table
func (*TableHandler) QueryRecords ¶
func (h *TableHandler) QueryRecords(w http.ResponseWriter, r *http.Request)
QueryRecords retrieves records from a table with optional filtering, sorting, field selection, and pagination. GET /api/v1/{serviceName}/_table/{tableName}
func (*TableHandler) ReplaceRecords ¶
func (h *TableHandler) ReplaceRecords(w http.ResponseWriter, r *http.Request)
ReplaceRecords performs a full record replacement (PUT) on a table. PUT /api/v1/{serviceName}/_table/{tableName}
Batch modes (query parameters):
- (default) halt on first error; prior updates are committed
- ?rollback=true wrap in transaction; all-or-nothing
- ?continue=true update each record independently; report mixed results
func (*TableHandler) UpdateRecords ¶
func (h *TableHandler) UpdateRecords(w http.ResponseWriter, r *http.Request)
UpdateRecords partially updates records matching a filter or ID list. PATCH /api/v1/{serviceName}/_table/{tableName}
Batch modes: ?rollback=true wraps the UPDATE in a transaction.