Documentation
¶
Overview ¶
Package datahubapi serves the portal's DataHub Catalog and Context Docs REST surface (#718): browse/search/read over DataHub connections plus catalog metadata edits and context-document CRUD, gated per-persona. It is a separate package from pkg/portal so the portal package stays within its size budget (#594); it plugs into the portal by registering its routes on the portal mux via a registrar hook, and reads the authenticated user through portal.GetUser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildConnection ¶
func BuildConnection(client *dhclient.Client, semanticPlatform string, catalogMapping map[string]string, readOnly bool) (Reader, Writer, error)
BuildConnection builds the read (and, when the connection is write-enabled, the write) surfaces for a live DataHub client. A read-only connection returns a nil writer. Both surfaces share the one client.
Types ¶
type Bridge ¶
type Bridge interface {
Connections() []Connection
Reader(conn string) (Reader, bool)
Writer(conn string) (Writer, bool)
}
Bridge exposes read/write access to the configured DataHub connections. Writer returns ok=false for an unknown or read-only connection, so a write against a read-only connection is rejected before any persona check.
type Connection ¶
Connection identifies a DataHub connection the portal can browse, and whether it is write-enabled (a connection with read_only=true is read-only no matter what tools the caller's persona grants).
type Deps ¶
type Deps struct {
Bridge Bridge
PersonaResolver portal.PersonaResolver
AdminRoles []string
Audit audit.Logger
}
Deps holds the handler dependencies. Bridge is required; Audit and PersonaResolver are optional (nil disables auditing / treats no persona as admin-only access).
type DocumentInput ¶
type DocumentInput struct {
ID string `json:"id,omitempty"`
EntityURN string `json:"entity_urn,omitempty"`
Title string `json:"title"`
Content string `json:"content"`
Category string `json:"category,omitempty"`
}
DocumentInput is a context-document create/update request. An empty ID creates a new document linked to EntityURN; a populated ID updates in place (EntityURN is then ignored, matching the upstream upsert contract).
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the portal DataHub REST endpoints.
type OwnerChange ¶
type OwnerChange struct {
OwnerURN string `json:"owner_urn"`
OwnershipType string `json:"ownership_type,omitempty"`
}
OwnerChange is an owner to add along with its ownership type.
type Reader ¶
type Reader interface {
ResolveURN(ctx context.Context, urn string) (*semantic.TableIdentifier, error)
GetTableContext(ctx context.Context, table semantic.TableIdentifier) (*semantic.TableContext, error)
GetColumnsContext(ctx context.Context, table semantic.TableIdentifier) (map[string]*semantic.ColumnContext, error)
SearchTables(ctx context.Context, filter semantic.SearchFilter) ([]semantic.TableSearchResult, error)
SearchTags(ctx context.Context, query string, limit int) ([]semantic.EntityRef, error)
SearchGlossaryTerms(ctx context.Context, query string, limit int) ([]semantic.EntityRef, error)
ListDomains(ctx context.Context) ([]semantic.EntityRef, error)
SearchDocuments(ctx context.Context, query string, limit int) ([]semantic.DocumentResult, error)
BrowseDocuments(ctx context.Context, offset, limit int) ([]semantic.DocumentResult, int, error)
GetDocument(ctx context.Context, urn string) (*semantic.DocumentResult, error)
}
Reader is the read surface the Catalog and Context Docs tabs need over a single DataHub connection. The semantic DataHub adapter (pkg/semantic/datahub) satisfies it directly, so the reader returns the semantic types the enrichment layer already uses rather than a portal-local mirror.
type StaticBridge ¶
type StaticBridge struct {
// contains filtered or unexported fields
}
StaticBridge is a Bridge assembled once at wiring time from a fixed set of per-connection read/write surfaces.
func NewStaticBridge ¶
func NewStaticBridge() *StaticBridge
NewStaticBridge returns an empty StaticBridge ready for Add.
func (*StaticBridge) Add ¶
func (b *StaticBridge) Add(name string, reader Reader, writer Writer)
Add registers a connection's surfaces. A nil writer marks the connection read-only (no writer is exposed for it).
func (*StaticBridge) Connections ¶
func (b *StaticBridge) Connections() []Connection
Connections returns the registered connections.
func (*StaticBridge) Empty ¶
func (b *StaticBridge) Empty() bool
Empty reports whether no connection was added.
type Writer ¶
type Writer interface {
UpdateDescription(ctx context.Context, urn, description string) error
ApplyTagChanges(ctx context.Context, urn string, add, remove []string) error
ApplyGlossaryTermChanges(ctx context.Context, urn string, add, remove []string) error
ApplyOwnerChanges(ctx context.Context, urn string, add []OwnerChange, remove []string) error
SetDomain(ctx context.Context, entityURN, domainURN string) error
UnsetDomain(ctx context.Context, entityURN string) error
UpsertContextDocument(ctx context.Context, in DocumentInput) (*semantic.DocumentResult, error)
DeleteContextDocument(ctx context.Context, documentID string) error
}
Writer is the write surface for catalog metadata edits and context-doc CRUD over a single write-enabled connection. Tags, glossary terms, and owners are applied as batched add/remove sets rather than per-item calls: per-item writes read-modify-write DataHub's eventually consistent aspects and clobber each other (#721/#729), so the batched forms are the only lossless primitives.